Repository navigation
fix: match the server's NATS subject encoding for segments with dots - #11
Merged
Merged
Conversation
The server now maps each URI segment to one subject token and percent-encodes every byte outside [A-Za-z0-9_-] with uppercase hex (priompt/priompt#33), so priompt://acme.corp/x/a.b publishes on priompt.acme%2Ecorp.x.a%2Eb. _subject() only replaced "/" with ".", so subscribe() listened on the wrong subject for any URI with a dot in a segment. Dot-free URIs keep the same subject. Fixes #10 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
priompt/priompt#33 changes the server's URI-to-subject mapping. Each URI segment becomes one subject token, and every byte outside
[A-Za-z0-9_-]is percent-encoded with uppercase hex (.becomes%2E)._subject()only replaced/with., so for a URI with a dot in a segment,subscribe()listened on a subject the server no longer publishes to, and hot reload got no events.Fix
_subject()now portspubsub.Subject/subjectTokenfrom #33: split on/, then encode each segment's UTF-8 bytes. Dot-free URIs map exactly as before.Tests
test_subjectcases:priompt://acme.corp/x/a.bmaps topriompt.acme%2Ecorp.x.a%2Eb, andagent-v2_xstays unchanged. Wildcard bytes and UTF-8 are encoded too.test_subject_is_injectiveuses the server's own collision pairs fromTestSubjectIsInjective:acme/a.bvsacme/a/b,acme/corp/xvsacme.corp/x, andacme/a.b/cvsacme/a/b.c.Parity with the server: a throwaway Go test on #33's branch (
91eb76b) printedSubject()for the same five URIs, and the output is identical to_subject():Real run against a server built from #33's branch: subscribe to both URIs, then publish to each.
Compatibility
This matches the server after #33. Against a v0.7.2 server, URIs with a dot in a segment would stop getting events, because that server still publishes on the unencoded subject. Dot-free URIs work with both. Release this in step with priompt/priompt#33.
Fixes #10
🤖 Generated with Claude Code