Repository navigation
fix(prolink): skip capabilities with no JSON form - #427
Open
pucedoteth wants to merge 1 commit into
Open
pucedoteth wants to merge 1 commit into
pucedoteth wants to merge 1 commit into
Conversation
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
Collaborator
🟡 Heimdall Review Status
|
This branch has not been deployed
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
encodeProlinkproduced links thatdecodeProlinkcould not decode when a capability value has no JSON form.encodeCapabilitiesrunsJSON.stringify(value), which returnsundefinedforundefined(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,parseMapEntrythrowsInvalid 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 asundefinedhit this.This skips such values in
encodeCapabilities, asJSON.stringifydoes for object members, so the decoded capabilities equal a JSON round trip of the input.How did you test your changes?
prolink/index.test.tscase "should skip capabilities whose value has no JSON form" (encode → decode end to end); it fails onmasterwith the error above.encodeCapabilitiesunit test inutils/encoding.test.ts.vitest --run src/interface/public-utilities/prolink: 206 tests pass.typecheckand Biome are clean.