Skip to content

fix!: escape keys in local reference pointers - #60

Merged
VisualBean merged 1 commit into
vnextfrom
fix/escape-reference-keys
Oct 24, 2026
Merged

VisualBean merged 1 commit into
vnextfrom
fix/escape-reference-keys

Conversation

@VisualBean

@VisualBean VisualBean commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Keys containing "/" or "~" were registered and referenced unescaped, so a spec-correct pointer such as "#/channels/user~1signedup" missed the workspace and was resolved from the raw document into a separate copy of the channel. Unescaped pointers only resolved because both sides skipped escaping.

The workspace now registers every component, channel, channel message and server under its escaped pointer, and the 2.x reader escapes the keys of every reference it builds. Names recovered from references (2.x message keys, 2.x channel servers and security requirement names) are taken from the parsed pointer, so they come back unescaped. This keeps 2.x and 3.x reading, writing, upgrading and downgrading intact for such keys.

BREAKING CHANGE: a local reference to a key containing "/" or "~" must escape it as "~1" or "~0" (RFC 6901). The unescaped form no longer resolves.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed local references to components, channels, messages, servers, and security schemes whose names contain / or ~, improving reference resolution and document round-tripping.
    • Corrected handling of server and security-scheme references during serialization, while preserving references that do not match the expected local format.

Keys containing "/" or "~" were registered and referenced unescaped, so a
spec-correct pointer such as "#/channels/user~1signedup" missed the workspace
and was resolved from the raw document into a separate copy of the channel.
Unescaped pointers only resolved because both sides skipped escaping.

The workspace now registers every component, channel, channel message and
server under its escaped pointer, and the 2.x reader escapes the keys of
every reference it builds. Names recovered from references (2.x message
keys, 2.x channel servers and security requirement names) are taken from
the parsed pointer, so they come back unescaped. This keeps 2.x and 3.x
reading, writing, upgrading and downgrading intact for such keys.

BREAKING CHANGE: a local reference to a key containing "/" or "~" must
escape it as "~1" or "~0" (RFC 6901). The unescaped form no longer resolves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

obfuscan report

Status: No findings.

Metric Value
Scanned files 10
Findings 0
Block 0
Warn 0
Info 0
Duration 20 ms
Engine 0.2.0
Rules 2026.04.0

No suspicious obfuscation or backdoor patterns were found in the scanned diff.

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 31bfbeca-3ca9-40bf-bb4b-78384727d62e
Commits

Reviewing files that changed from the base of the PR and between 7ed7e04 and 74c415e.

Files selected for processing: 10
  • src/ByteBard.AsyncAPI.Readers/V2/AsyncApiChannelDeserializer.cs
  • src/ByteBard.AsyncAPI.Readers/V2/AsyncApiDocumentDeserializer.cs
  • src/ByteBard.AsyncAPI.Readers/V2/AsyncApiOperationDeserializer.cs
  • src/ByteBard.AsyncAPI.Readers/V2/AsyncApiSecurityRequirementDeserializer.cs
  • src/ByteBard.AsyncAPI/AsyncApiWorkspace.cs
  • src/ByteBard.AsyncAPI/JsonPointer.cs
  • src/ByteBard.AsyncAPI/Models/AsyncApiChannel.cs
  • src/ByteBard.AsyncAPI/Models/References/AsyncApiSecuritySchemeReference.cs
  • test/ByteBard.AsyncAPI.Tests/JsonPointer_Should.cs
  • test/ByteBard.AsyncAPI.Tests/Models/EscapedReferenceKeys_Should.cs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The change adds JSON Pointer token escaping and parsing support. Workspace registration and V2 readers use escaped keys in reference paths. Serializers and tests cover escaped references across AsyncAPI versions.

Changes: Escaped Reference Keys

Layer / File(s) Summary
JSON Pointer token utilities
src/ByteBard.AsyncAPI/JsonPointer.cs, test/ByteBard.AsyncAPI.Tests/JsonPointer_Should.cs
JsonPointer adds EscapeToken and TryFromUriFragment. ToString uses the shared token-escaping method.
Reference registration and V2 reading
src/ByteBard.AsyncAPI/AsyncApiWorkspace.cs, src/ByteBard.AsyncAPI.Readers/V2/*
Workspace locations and V2 reader-created references escape keys. Message references use the final unescaped pointer token when parsing succeeds.
Reference serialization and cross-version tests
src/ByteBard.AsyncAPI/Models/AsyncApiChannel.cs, src/ByteBard.AsyncAPI/Models/References/AsyncApiSecuritySchemeReference.cs, test/ByteBard.AsyncAPI.Tests/Models/EscapedReferenceKeys_Should.cs
V2 channel and security serialization derive names from parsed pointers. Tests cover reference resolution, serialization round trips, and version upgrades and downgrades.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

Suggested reviewers: bielu

Merge Risk: Minimal · up to 74c41

No confirmed issue blocks merging after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 17.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 28 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title "fix!: escape keys in local reference pointers" matches the main change. The PR makes the workspace and the 2.x reader escape keys containing "/" or "~" in local JSON Pointer references (RFC…
Description check Passed The description covers the problem, the fix, and the breaking change. It explains that keys containing "/" or "~" were registered and referenced unescaped, and that the workspace now registers compone…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix!: escape keys in local reference pointers" matches the main change. The PR makes the workspace and the 2.x reader escape keys containing "/" or "~" in local JSON Pointer references (RFC 6901). The "!" marks the breaking change, since unescaped local references no longer resolve. The title is concise and specific, and it names the primary behavior change.

Full details: Description check

Explanation

The description covers the problem, the fix, and the breaking change. It explains that keys containing "/" or "~" were registered and referenced unescaped, and that the workspace now registers components, channels, channel messages, and servers under escaped pointers. It also describes how the 2.x reader escapes reference keys and how names recovered from references are unescaped. It states the BREAKING CHANGE clearly. The template's "Changelog" section (Add/Remove entries) and "Related Issues" section (Closes #...) are missing, so the description only partly follows the template.

Resolution

Consider adding the "Changelog" section with an entry such as "Fix: local references to keys containing '/' or '~' now use RFC 6901 escaping" and the "Related Issues" section with a closing reference (for example, "Closes #<issue-number>") if an issue exists.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@VisualBean

VisualBean commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor Author

@bielu this might make your channels PR partially obsolete.
I noticed a thing.

@bielu

bielu commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

@VisualBean yep you made my pr redudant :)

@VisualBean

Copy link
Copy Markdown
Contributor Author

I see you point on the preencoded values, but will leave it for now.
#61

@VisualBean
VisualBean merged commit ff96a92 into vnext Oct 24, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants