AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 21 Bitcoin

btcjson: accept null in StringOrArray.UnmarshalJSON

Public commit record

What the developer wrote

Authored by Calvin Kim

83/100 · Strong
btcjson: accept null in StringOrArray.UnmarshalJSON

StringOrArray.MarshalJSON emits JSON null for a nil slice (see existing
test "nil slice marshals as null" in TestStringOrArrayMarshalJSON), but
UnmarshalJSON did not have a matching case for null and fell to the
default branch, returning "invalid string_or_array value: <nil>". A
round trip of a nil slice therefore failed.

This bit the rpcclient against btcd's own getblockchaininfo, whose
Warnings field is a StringOrArray that the server leaves as a nil slice
when there are no warnings. Every rpctest integration test that touches
GetBlockChainInfo (TestBIP0009, TestBIP0068AndBIP0112Activation,
TestBIP0113Activation, TestPrune) failed to decode the response.

Handle the nil case explicitly so null decodes back to a nil slice, and
add regression cases for "warnings: null" and an omitted warnings field
to TestGetBlockChainInfoWarnings.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit fixes a harmless JSON decoding bug. When a Bitcoin RPC server returned a null value for the 'warnings' field, the client couldn't understand it and threw an error. The fix lets null decode to an empty list, restoring normal operation. There is no security attack here.

Recommended action

No security action required; treat as a normal bug fix. If desired, ensure integration tests covering getblockchaininfo pass after the change.

Security signals we found

01

No security-relevant signals present

02

Fix is a deserialization compatibility correction, not a vulnerability patch

03

No input validation, authentication, cryptography, or resource-control changes

Risk score

Why this scored 21/100

Our methodology →
Potential impact 2/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 5/15
Confidence 9/10
Evidence quality 5/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.