Conversation
Type keys were incorrectly encoded as CBOR array [type, body]. Spec requires: [varint type key][CBOR body]
Summary of ChangesHello @backkem, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the data encoding strategies within the OpenScreen Protocol implementation. It specifically addresses a compatibility concern by adopting URL-safe Base64 for certificate serial numbers, making them suitable for use in DNS labels. Furthermore, it overhauls the network message serialization by introducing RFC 9000 variable-length integer encoding for message type keys, aligning the protocol's message structure more closely with its specification and improving efficiency by removing redundant CBOR array wrappers. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request updates the message encoding to use a variable-length integer for the type key, prefixed to the CBOR message body, instead of a CBOR array. It also correctly switches to URL-safe Base64 encoding for certificate serial numbers to ensure they are valid in DNS labels. The changes are logical and well-motivated. I've found one critical issue that will prevent compilation due to an API change in a dependency, and one medium-severity issue related to code structure and efficiency. My detailed feedback is in the comments below.
Standard base64 contains +/= which are invalid in DNS labels. Use URL_SAFE_NO_PAD encoding per w3c/openscreenprotocol#365.
1c639ce to
1cbd2f3
Compare
|
PTAL @kaidokert |
|
Thank you - looks like a good fix. But that CBOR-array encoding is much more widespread, for all other app level messages too, i'll do a follow-up fix. I had completely misinterpreted the type key encoding |
|
Fixed lint & did the application messages while at it. |
d74d5ac to
ee7a55d
Compare
|
Sorry for the back-n-forth. I realize I normally rely a bit too much on just running the CI a couple times 😅 Will do better. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request correctly implements two important fixes: using RFC 9000 varint for message type key encoding and URL-safe base64 for hostnames. The changes are well-implemented, especially the refactoring of decode logic into decode_body functions, which fixes a bug in the previous implementation where the full buffer was passed for body decoding. The use of URL_SAFE_NO_PAD for base64 encoding is also correct for DNS compatibility. I have one suggestion to reduce code duplication for the new helper functions.
|
Thanks a lot ! This was very off spec |
Summary
Details
Message encoding (Issue #8): The spec requires message format
[varint type_key][CBOR body], but we were encodingas
[CBOR array][CBOR u16 type][CBOR body]. Fixed by usingquinn_varintfor type keys.Hostname encoding (Issue #9): Standard base64 contains
+,/,=which are invalid in DNS labels and TLS SNI.Changed to
URL_SAFE_NO_PADencoding. See w3c/openscreenprotocol#365.