fix(relay): guard multi-value #h filters from collapsing to one channel - #4693
Open
santhiprakash wants to merge 1 commit into
Open
fix(relay): guard multi-value #h filters from collapsing to one channel#4693santhiprakash wants to merge 1 commit into
santhiprakash wants to merge 1 commit into
Conversation
extract_channel_id_from_filter previously returned the first parseable UUID from a multi-value #h tag, so a POST /query filter listing multiple channel UUIDs silently collapsed to whichever channel sorted first. NIP-01 treats a multi-value tag as OR, so the filter must be handled by the Rust-side filters_match post-filter instead of being pinned to a single channel_id SQL predicate. Match the existing guard in bridge.rs::extract_channel_from_filter and the WS REQ path: only set channel_id when the filter contains exactly one #h value and it is a parseable UUID. Add focused regression tests. Fixes block#4659 Signed-off-by: Santhi Prakash <b.santhiprakash@gmail.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.
Summary
extract_channel_id_from_filterincrates/buzz-relay/src/handlers/req.rspreviously returned the first parseable UUID out of a multi-value#htag. This causedPOST /queryfilters listing multiple channel UUIDs to silently collapse to whichever channel sorted first ingeneric_tags, turning a NIP-01 OR-semantics filter into an AND-of-one against a single arbitrary channel before the correctfilters_matchpost-filter could run.This change adds the same arity guard already present in
bridge.rs::extract_channel_from_filterand in the WS REQ path (extract_channel_id_from_filters):channel_idis only set when the filter contains exactly one#hvalue and it is a parseable UUID. Multi-value#hfilters now leavechannel_idunset so the existing Rust-side post-filter handles the OR semantics correctly.Related issue
Fixes #4659
Testing
cargo test -p buzz-relay handlers::req— all 52 tests pass, including 5 new focused regression tests:extract_channel_id_from_filter_single_hextract_channel_id_from_filter_multi_h_returns_noneextract_channel_id_from_filter_no_h_returns_noneextract_channel_id_from_filter_invalid_h_returns_nonebuild_event_query_from_filter_multi_h_leaves_channel_id_unsetcargo fmt --all -- --checkpassescargo clippy -p buzz-relay --all-targets --all-features -- -D warningspasses