Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

content deserialize failed #2892

Open
Rubick-hqm opened this issue Feb 17, 2025 · 0 comments
Open

content deserialize failed #2892

Rubick-hqm opened this issue Feb 17, 2025 · 0 comments

Comments

@Rubick-hqm
Copy link

Hi!
Recently, I use bendy to parse bencode, defined the following struct:

    #[derive(Debug, Serialize, Deserialize, PartialEq)]
    #[serde(tag = "q", content = "a")]
    enum QueryMessage {
        AnnouncePeer {
            implied_port: bool,
        },
    }

Serialization succeeds, producing the byte string:
b"d1:ad12:implied_porti1ee1:q12:AnnouncePeere".
However, deserialization fails with the error:
CustomDecode("invalid type: integer 1, expected a boolean").

The problem seems to be that the Bencode protocol parses boolean values as i64 (integers), but the deserialization logic for the implied_port field only considers boolean values.
Should the deserialization logic be modified to also handle integer cases?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant