fix(cli): canonicalize the channel id channel and message queries filter on - #6877
Open
Chessing234 wants to merge 1 commit into
Open
fix(cli): canonicalize the channel id channel and message queries filter on#6877Chessing234 wants to merge 1 commit into
Chessing234 wants to merge 1 commit into
Conversation
…ter on validate_uuid checks that the argument parses and throws the result away. Uuid::parse_str accepts uppercase, the unhyphenated 32-character form, braces and a urn:uuid: prefix, so all four reach the filter unchanged. Every h and d tag in the tree is written in the canonical lowercase hyphenated form, and a NIP-01 generic tag filter compares tag values byte for byte. A non-canonical spelling therefore matches nothing, and each of these commands prints an empty result rather than an error: channels get, channels members, channels canvas, messages list, messages thread The send path is unaffected: it parses the argument into a Uuid and hands that to the SDK builders, which write the canonical form. The one place that leaked into a send is the mention preflight, which filtered on the raw string and so failed with "could not load channel membership" instead of the parse error the input deserves. Parse once and filter on the canonical form. messages thread already had the parsed value to hand and was still building its filters from the raw argument. Signed-off-by: Taksh <takshkothari09@gmail.com>
This was referenced Aug 26, 2026
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.
Found by reading
validate_uuidagainst its callers; no issue filed.validate_uuidchecks that its argument parses and discards the result.Uuid::parse_stris deliberately lenient — it accepts uppercase, the unhyphenated 32-character form, braces, and aurn:uuid:prefix — so all four spellings pass and then reach a filter unchanged:Every
handdtag in the tree is written in the canonical lowercase hyphenated form, and a NIP-01 generic tag filter compares tag values byte for byte (filter_match_one). So a non-canonical spelling matches nothing, and the command reports that as no results rather than as bad input:Five commands are affected:
channels get,channels members,channels canvas,messages list,messages thread.What is not affected
The send path is fine, and it's worth saying why.
cmd_send_messagedoesparse_uuid(&p.channel_id)?and hands the typedUuidto the SDK builders, which write the canonical form — so a message sent with a non-canonical--channelstill lands with a correcthtag. Nothing is published wrong by this bug.The one place it leaks into a send is the mention preflight:
resolve_content_mentionsreceives the raw argument and filters{"kinds":[39002], "#d":[channel_id]}on it, so with an@in the content the send fails withwhich is a confusing way to say "your channel id isn't in the form the relay stores".
The change
Parse once, filter on the canonical form.
messages threadis the clearest case — it already hadlet expected_channel_id = parse_uuid(channel_id)?on the line above and was still building both filters from the raw argument.Two unit tests in
validate.rscarry the reasoning: one asserts thatvalidate_uuidreally does pass all four non-canonical spellings (so it fails loudly if the leniency ever changes and this canonicalization becomes unnecessary), and one asserts thatparse_uuid(...).hyphenated().to_string()collapses every spelling onto the single form the relay stores.Related
Same root cause as, but independent of, #5966 / #5970 / #5984, which fix the hex-id half of this (
validate_hex64documented as lowercase, implemented withis_ascii_hexdigit). This is the UUID half. The same gap remains inworkflows,reposandprojects; those are separate diffs.Testing
cargo test -p buzz-cli --lib— 365 passed, 0 failedcargo clippy -p buzz-cli --all-targets— cleancargo fmt --all -- --check— cleanI have not exercised these commands against a live relay; the claim about byte-for-byte tag matching is read from
filter_match_oneand from the fact that nothing in the relay's ingest path canonicalizes anh/dtag before storing it.