Skip to content

fix(channels): request GRP_TXT packets with type=5, the parameter the API reads (#2515) - #2518

Merged
efiten merged 1 commit into
Kpa-clawbot:masterfrom
zfouts:fix/channels-type-param
Dec 1, 2026
Merged

efiten merged 1 commit into
Kpa-clawbot:masterfrom
zfouts:fix/channels-type-param

Conversation

@zfouts

@zfouts zfouts commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

What was wrong

Client-side channel decryption in public/channels.js fetched

/api/packets?limit=1000&payloadType=5

but /api/packets reads the payload type filter from type (cmd/server/routes.go, r.URL.Query().Get("type")). payloadType was ignored, so the request returned the 1000 newest packets of every type, and channels.js discarded everything that was not GRP_TXT/CHAN. On a busy mesh only a fraction of that window were channel packets, so decrypted channel history was much shorter than the limit suggests.

Fix

Send type=5 (GRP_TXT). Both the in-memory store and the SQLite path filter payload_type on it, and existing Go tests already cover ?type= on /api/packets. The candidate loop still checks the decoded type and channel hash, so it is unchanged; limit=1000 now means 1000 channel packets. No other code in public/ sends payloadType=.

Tests

  • New case in tests/unit/test-issue-1851-channel-message-scope.js: drives the real channels.js through selectChannel with a user key and asserts the /packets request carries type=5, limit=1000 and no payloadType. It fails before the fix and passes after.
  • sh test-all.sh: all suites pass.
  • eslint public/*.js: 0 errors.

Browser validation was not done.

Closes #2515

🤖 Generated with Claude Code

… API reads (Kpa-clawbot#2515)

Client-side channel decryption fetched /api/packets?limit=1000&payloadType=5,
but the packets endpoint only reads `type` (cmd/server/routes.go). The
filter was dropped, so the 1000 newest rows of every payload type came back
and channels.js threw away everything that was not GRP_TXT/CHAN. On a busy
mesh that left only a fraction of the window as channel candidates, so
decrypted channel history was much shorter than the limit implies.

The request now sends type=5, which both the in-memory store and the SQLite
path filter on payload_type. The candidate loop already checked the decoded
type and channel hash, so it is unchanged; limit=1000 now means 1000 channel
packets. No other public/ code sends payloadType=.

The new test in test-issue-1851-channel-message-scope.js drives the real
channels.js through selectChannel with a user key and asserts the /packets
request carries type=5 and no payloadType. It fails before the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zfouts
zfouts marked this pull request as ready for review December 1, 2026 20:02
@efiten
efiten merged commit 0e90b14 into Kpa-clawbot:master Dec 1, 2026
17 checks passed
zfouts added a commit to zfouts/CoreScope that referenced this pull request Dec 2, 2026
… and the advert reception changes to Postgres

Brings in 10 master commits: Kpa-clawbot#2366 (catalogue key tier), Kpa-clawbot#2497 (regions
count only received adverts), Kpa-clawbot#2498 (archived foreign-advert flags), Kpa-clawbot#2492
(observer comparison), Kpa-clawbot#2511, Kpa-clawbot#2513, Kpa-clawbot#2514, Kpa-clawbot#2517, Kpa-clawbot#2518, Kpa-clawbot#2519.

Conflicts:
- cmd/ingestor/approved_channels.go: both sides added a mutex to
  channelKeySet. One mu now serialises refresh, master's setCatalog and the
  branch's Close, and guards the users.db/Postgres accounts readers as well
  as master's approvedNames and catalogue tier.
- cmd/ingestor/db.go, nodes upsert: master's foreign_advert carry-over on
  top of the branch's qualified columns and lastSeenClampSQL. Master looked
  up the archived flag with ?1, which dbx.Rebind turns into $11 on Postgres;
  it is now a plain ? bound to the public key again, and the EXISTS is
  wrapped in CASE so Postgres stores 0/1 in the BIGINT column.
- cmd/ingestor/db.go, MoveStaleNodes: master's UPDATE that restores an
  archived foreign flag runs before the branch's portable moveStaleNodesSQL
  (not master's INSERT OR REPLACE ... SELECT *), with IS DISTINCT FROM 1
  instead of the SQLite-only IS NOT 1.

Ported to Postgres:
- catalog_keys (Kpa-clawbot#2366): pgschema migration 0004_catalog_keys.sql (same
  columns, CHECKs, defaults and key; LatestVersion 4), the table in
  sqlite_endstate.sql, and the worker's upsert sets updated_at from
  excluded.updated_at instead of strftime('%s','now').
- corescope-migrate copies catalog_keys and verify never prints
  catalog_keys.key_hex (channel secrets), for any store.
- GetNodes region filter (Kpa-clawbot#2497) and the observer comparison (Kpa-clawbot#2492) used
  IS NOT 'tx'; both use IS DISTINCT FROM 'tx'. The comparison's
  ORDER BY label COLLATE NOCASE is lower(<label expression>) on Postgres,
  which folds ASCII only under COLLATE "C", as NOCASE does.
- docs/catalogue-keys.md: the revert SQL on PostgreSQL.

Tests on both backends:
- The catalogue key tests that use a store and the Kpa-clawbot#2498 foreign-advert
  tests run on SQLite and Postgres (onBothStores; insertTx uses RETURNING).
- New dual tests for the observer comparison and the GetNodes region filter.
- pgschema: an upgrade from version 3 with data; the control migration tests
  no longer assume 3 is the latest version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

bug: wrong parameter name in channels.js API call

2 participants