fix(relay): stop collapsing multi-value #h filters to a single channel - #2452
fix(relay): stop collapsing multi-value #h filters to a single channel#2452taehalim wants to merge 1 commit into
Conversation
c4d6250 to
b52f83f
Compare
extract_channel_id_from_filter returned the first parseable #h value even when a filter listed several distinct channels. Filter tag values live in a BTreeSet, so /query and the COUNT fallback silently pinned the SQL query to the lexicographically-first channel UUID and dropped every other listed channel's events — the desktop Workflows overview rendered empty because get_channels_workflows batches all member channels into one #h filter. Return None for multi-#h filters instead, mirroring the multi-filter rule in extract_channel_id_from_filters: the access-scope path then widens the SQL query to the caller's accessible channels and the filters_match post-filter enforces the per-event #h OR. Fixes block#2385 Signed-off-by: taeha <uv.taeha@gmail.com>
b52f83f to
f6ec66b
Compare
|
Independently hit this on a hosted community relay: Workflows overview shows "No workflows yet" despite a live kind:30620 in a joined channel. Reproduced the collapse with signed |
|
Bumping with fresh signal: three independent repros now — #2373 (Desktop Workflows overview empty) plus two hosted-relay confirmations in this thread and #2385, all tracing to the same |
|
Another self-hosted operator blocked by this — confirming on Desktop 0.5.3 against a self-hosted relay, and adding one detail I did not find in #2385 or #4419: There is no UI workaround. Both code paths that would be unaffected by the multi-
So the impact goes beyond visibility: an owner cannot reach their workflows through the UI at all. In our case that produced four duplicate scheduled workflows — each created because the previous one never appeared — which then had to be removed with Single-channel CLI reads return everything correctly, consistent with the analysis in #2385. Happy to test a build against a self-hosted relay if that helps. |
|
Production verification from a self-hosted relay — this patch fixes the reported symptom end to end. Setup. Built the relay image from Before. Several member channels, with the channel owning the workflow not sorting first. The Workflows overview showed After. No client change, no cache clear, no re-login — the Workflows overview lists the workflow on first load, with its schedule and description rendered correctly. One observation that may be useful for reviewers: the scheduler was never affected. The workflow kept firing on its cron throughout, since that path reads the database directly and never goes through the bridge. The blast radius really is visibility-only — but a user watching an empty overview cannot distinguish a broken list from a workflow that failed to save, which is how duplicate workflows get created (as @ngavelek reported above). Scope of what I tested: the Happy to run any additional check against the patched deployment if that would help land this. No relay hostname, community or channel names, UUIDs, public keys, IP addresses, or workflow content are included in this report. |
Problem
Fixes #2385.
A filter listing multiple distinct
#hchannels should match events from any of them (NIP-01 OR semantics), butextract_channel_id_from_filterinhandlers/req.rsreturned the first parseable value from the tagBTreeSet— i.e. the lexicographically-first channel UUID. Throughbuild_event_query_from_filterthis pinnedquery.channel_idto that single channel, so:POST /query(bridge catchall) composed a contradictory SQL query (channel_id = $firstAND-ed with the access scope) and dropped every other listed channel's events — this is why the desktop Workflows overview renders empty:get_channels_workflowsbatches all member channels into one#hfilter.POST /count) undercounted for the same reason.Fix
extract_channel_id_from_filternow returnsNonewhen the filter carries multiple distinct parseable#hUUIDs, mirroring the existing multi-filter rule inextract_channel_id_from_filters. Callers then take the access-scope path (apply_access_scope_to_querywidens the SQL query to the caller's accessible channels) and thefilters_matchpost-filter enforces the per-event#hOR — the same shape the WS REQ path already uses.A filter whose
#hvalues resolve to a single channel (duplicates, or unparseable extras alongside one UUID) still pins that channel, keeping the narrower SQL predicate.Testing
test_query_multi_h_filter_returns_all_listed_channels: two channels, one message each;POST /querywith both ids in one#hfilter must return both events, andPOST /countmust count both. Verified it fails onmainwith exactly the reported symptom (only the lexicographically-first channel's event comes back) and passes with this fix.cargo fmt+clippy --all-targets --all-featuresclean on the touched crates; fulle2e_relaysuite run against a local relay — 36/39 pass, and the 3 failures (invite mint, subscription limit, unarchive notification) fail identically onmain, so they're local-env issues unrelated to this change.