Skip to content

fix(prolink): skip capabilities with no JSON form - #427

Open
pucedoteth wants to merge 1 commit into
base:masterfrom
pucedoteth:fix/prolink-undefined-capability
Open

pucedoteth wants to merge 1 commit into
base:masterfrom
pucedoteth:fix/prolink-undefined-capability

Conversation

@pucedoteth

Copy link
Copy Markdown

Summary

encodeProlink produced links that decodeProlink could not decode when a capability value has no JSON form. encodeCapabilities runs JSON.stringify(value), which returns undefined for undefined (and for functions); TextEncoder.encode(undefined) gives empty bytes, and the protobuf encoder omits empty bytes, so the capabilities map entry was written with a key and no value. On decode, parseMapEntry throws Invalid map entry: missing key or value.

Repro: decodeProlink(await encodeProlink({ method: 'wallet_sendCalls', params: [...], capabilities: { order_id: 'X', paymasterService: undefined } })) throws. Optional capabilities spread in as undefined hit this.

This skips such values in encodeCapabilities, as JSON.stringify does for object members, so the decoded capabilities equal a JSON round trip of the input.

How did you test your changes?

  • New prolink/index.test.ts case "should skip capabilities whose value has no JSON form" (encode → decode end to end); it fails on master with the error above.
  • New encodeCapabilities unit test in utils/encoding.test.ts.
  • vitest --run src/interface/public-utilities/prolink: 206 tests pass. typecheck and Biome are clean.

encodeCapabilities encoded a value whose JSON.stringify is undefined (undefined, a function) as empty bytes. The protobuf encoder omits empty bytes, so the map entry was written with a key and no value, and decodeProlink threw "Invalid map entry: missing key or value" on a link encodeProlink had produced, e.g. for capabilities { paymasterService: undefined }. Skip such values, as JSON.stringify does for object members.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L75E8Ap183JW1mDfv8arqR
@cb-heimdall

Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
1 if authored by an app that is not allowlisted and lacks verified human attribution 0
Sum 1

This branch has not been deployed

No deployments
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.

2 participants