Skip to content

fix(cmc): readOffer must use streams not streamIds on events.get#67

Closed
perki wants to merge 1 commit into
masterfrom
hds/fix-cmc-readOffer-streams
Closed

fix(cmc): readOffer must use streams not streamIds on events.get#67
perki wants to merge 1 commit into
masterfrom
hds/fix-cmc-readOffer-streams

Conversation

@perki
Copy link
Copy Markdown
Member

@perki perki commented May 19, 2026

Problem

readOffer (components/pryv-cmc/src/index.js:553-556) calls events.get with {streamIds: [NS_INTERNAL + ':offer'], limit: 1}. The api-server's events.get schema rejects this with:

{"id":"invalid-parameters-format",
 "data":[{"code":"OBJECT_ADDITIONAL_PROPERTIES","params":["streamIds"]}]}

events.get takes streams (recursive read filter); streamIds is the events.create write target. Every readOffer call fails against every deploy.

The four other events.get callers in this file (listInvites:374-375, waitForAccept:445-446, listAcceptedRelationships:827-828, acceptScopeUpdate:982) all already use streams correctly — this is an isolated typo.

Fix

Change streamIdsstreams in readOffer. 1-line behavioural change plus a clarifying comment.

Visible impact pre-fix

Any caller of cmc.readOffer(capabilityUrl) throws on the first await. Patient apps can't peek the offer (display title/description/permissions) before clicking accept. HDS's plan-59 Phase-5a UX needs this primitive to render the offer-preview screen.

Test

No new tests in this PR — the existing cmc.test.js suite mocks Connection.apiOne and doesn't exercise the wire-shape, so the schema mismatch slipped past unit coverage. The downstream behavior is exercised end-to-end against a deployed open-pryv.io via HDS's _plans/59-pryv-cmc-integration-atwork/tests/08-sdk-handshake.js (PASS post-fix).

If you'd like, I can add a contract test that asserts the underlying Connection call uses streams — let me know.

`readOffer` was calling `events.get` with `streamIds: [...]` which
the api-server schema rejects with OBJECT_ADDITIONAL_PROPERTIES.
`events.get` takes `streams` (recursive read filter); `streamIds` is
the `events.create` write target. The four other `events.get` callers
in this file (listInvites, waitForAccept, listAcceptedRelationships)
all already use `streams` correctly.

Reproduces 100% against any open-pryv.io running the CMC plugin —
any `cmc.readOffer(capabilityUrl)` call throws on the first await.

No new tests in this PR — existing cmc.test.js suite mocks the
Connection.apiOne layer and doesn't exercise the wire-shape; the
schema mismatch only surfaces against a real api-server. End-to-end
verification via an HDS-side scenario test runs green post-fix.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@perki
Copy link
Copy Markdown
Member Author

perki commented May 19, 2026

Merged into master at 5f53ab9 (2 commits: 3b2e6f4, 5f53ab9).

Added a follow-up commit (5f53ab9) with a contract test that stubs pryv.Connection so the inner apiOne('events.get', …) wire-shape can be asserted. The same shape of test would have caught this typo at unit-test time.

Thanks!

@perki perki closed this May 19, 2026
perki added a commit that referenced this pull request May 19, 2026
The contract test was asserting the buggy intermediate shape from PR
#67 (`streams: [':_cmc:_internal:offer']`). PR #68 corrected that to
omit the streams filter entirely (parent stream isn't auto-provisioned).
Update the assertion to match the final correct wire-shape: no `streams`,
no `streamIds`, with `types: ['consent/request-cmc']` as the only filter.
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.

1 participant