-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: don't treat arrays/objects as string literals for composite methods #6943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ No Merge Conflicts DetectedThis PR currently has no conflicts with other open PRs. |
d4e9a0b to
50f6697
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
WalkthroughThe RPC parameter conversion was refactored to support conditional parsing of non-string JSON values. CRPCConvertTable now stores conversion rules in maps keyed by (method, index) and (method, name) with a boolean preserve_str flag per entry. New helpers MaybeUnquoteString and LikelyJSONType detect quoted JSON-like inputs. ArgToUniValue and RPC conversion entry points consult the maps and preserve_str to decide whether to ParseNonRFCJSONValue or keep arguments as strings. RPCConvertValues/RPCConvertNamedValues adjust method names for composite subcommands using a new IsDefined method. Tests and RPC-help parsing were updated for composite commands. Sequence DiagramsequenceDiagram
participant Caller
participant RPCConvert as RPCConvertValues()/RPCConvertNamedValues()
participant CRPCTable as CRPCConvertTable
participant ArgToUni as ArgToUniValue
participant LikelyJSON as LikelyJSONType
participant MaybeUnq as MaybeUnquoteString
Caller->>RPCConvert: strMethod, strParams[]
Note over RPCConvert,CRPCTable: Determine whether a composite subcommand exists
RPCConvert->>CRPCTable: IsDefined(candidateMethod, named?)
CRPCTable-->>RPCConvert: true/false
alt composite found
RPCConvert->>RPCConvert: adjust strMethod to "method subcmd"
end
loop for each param
RPCConvert->>CRPCTable: lookup preserve_str for (strMethod, idx/name)
CRPCTable-->>RPCConvert: preserve_str (bool)
RPCConvert->>ArgToUni: paramStr, preserve_str
ArgToUni->>MaybeUnq: MaybeUnquoteString(paramStr)
MaybeUnq-->>ArgToUni: possibly_unquoted
ArgToUni->>LikelyJSON: LikelyJSONType(possibly_unquoted)
LikelyJSON-->>ArgToUni: isJSON
alt preserve_str == false AND isJSON == true
ArgToUni->>ArgToUni: ParseNonRFCJSONValue(possibly_unquoted)
else
ArgToUni->>ArgToUni: return string value
end
ArgToUni-->>RPCConvert: UniValue
end
RPCConvert-->>Caller: UniValue array/object result
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (2)
🧰 Additional context used📓 Path-based instructions (1)src/**/*.{cpp,h,cc,cxx,hpp}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (2)📓 Common learnings📚 Learning: 2025-08-08T07:01:47.332ZApplied to files:
🧬 Code graph analysis (1)src/rpc/client.h (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
🔇 Additional comments (10)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
9da6fe0 to
1894c4d
Compare
We currently do not process them as numbers or other non-string types as this current fix aims to preserve the string representation as expected by RPCs that support extended addresses. A future improvement could allow for full integration but that is currently out of scope.
UdjinM6
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 5978985
…s for composite methods 5978985 fix: don't treat arrays/objects as string literals for composite methods (Kittywhiskers Van Gogh) Pull request description: ## Additional Information thephez identified a bug where attempting to specify arrays as expected by `coreP2PAddrs`, `platformHTTPSAddrs` or `platformP2PAddrs` using `dash-cli` or the Qt wallet resulted in errors (see below) ``` $ ./src/dash-cli --testnet protx register_prepare "6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000" 1 '["1.1.1.1:19999"]' "yhq7ifNCtTKEpY4Yu5XPCcztQco6Fh6JsZ" "93746e8731c57f87f79b3620a7982924e2931717d49540a85864bd543de11c43fb868fd63e501a1db37e19ed59ae6db4" "yTretFTpoi3oQ3maZk5QadGaDWPiKnmDBc" 0 "yNbNZyCiTYSFtDwEXt7jChV7tZVYX862ua" error code: -8 error message: Error setting coreP2PAddrs[0] to '["1.1.1.1:19999"]' (invalid input) ``` This was not caught by functional tests as they send fully formed JSON messages and do not require JSON client interpretation, which both `dash-cli` and Dash Qt require, this pull request adds additional handling to ensure that arrays and objects are interpreted if they are likely to be so (starting and ending with curly or square brackets) or otherwise passed as-is as a string. What this pull request _isn't_ is full fledged conversion support for composite RPC arguments to other non-string types like integers, the scope here is specifically to allow for the backwards compatibility logic for `coreP2PAddrs`, `platformHTTPSAddrs` or `platformP2PAddrs` to work as intended. With this pull request, the following result is expected (see below) ``` $ ./src/dash-cli --testnet protx register_prepare "6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000" 1 '["1.1.1.1:19999"]' "yhq7ifNCtTKEpY4Yu5XPCcztQco6Fh6JsZ" "93746e8731c57f87f79b3620a7982924e2931717d49540a85864bd543de11c43fb868fd63e501a1db37e19ed59ae6db4" "yTretFTpoi3oQ3maZk5QadGaDWPiKnmDBc" 0 "yNbNZyCiTYSFtDwEXt7jChV7tZVYX862ua" error code: -32603 error message: No funds at specified address yNbNZyCiTYSFtDwEXt7jChV7tZVYX862ua ``` ## Breaking Changes None expected. ## Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have added or updated relevant unit/integration/functional/e2e tests - [x] I have made corresponding changes to the documentation **(note: N/A)** - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: utACK 5978985 Tree-SHA512: 9271d7a4c5f463611a10c7edcb0cea929d6d7e0c07d6b962f4aca40483f84ff17b29e3d6b84c465c267734ff6e93e2148e11af0ad19ce58585ed3200fc3e3b01
6fd7059 chore: mark v23 as release (pasta) ae08f53 docs: integrate 6946 release notes into final (pasta) 74a222d Merge #6946: feat: show seed on wallet creation (pasta) 877343a Merge #6943: fix: don't treat arrays/objects as string literals for composite methods (pasta) 00368fb Merge #6940: fix: reuse best clsig to avoid potential race condition (pasta) 8eceb98 Merge #6938: fix: logic error in `CheckDecryptionKey` (pasta) 3f30664 Merge #6929: fix: repair `makeseeds.py`, `getblockchaininfo[softforks]` help text, drop extra `generate`s from test, resolve macOS GID issue (pasta) 7ba4f1c Merge #6928: docs: update man pages for 23.0 (pasta) a6c1d6a Merge #6920: chore: update minimum chain work, tx stats, checkpoints, seeds and SECURITY.md for v23 (pasta) 84df1f0 Merge #6909: chore: Translations 2025-10 (pasta) a6449b1 Merge #6885: fix: improve governance/proposal dialog strings (pasta) Pull request description: ## Issue being fixed or feature implemented See commits ## Checklist: _Go over all the following points, and put an `x` in all the boxes that apply._ - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: utACK 6fd7059 Tree-SHA512: a0d93a61a4f4978fbe120bea832ce683a8ae7c16c892a381d91ddc4b25344c0f3ad3306a1a30a166a7dfa6e38e4532708587cc23cc372126828b8e22d141dc85
Additional Information
thephez identified a bug where attempting to specify arrays as expected by
coreP2PAddrs,platformHTTPSAddrsorplatformP2PAddrsusingdash-clior the Qt wallet resulted in errors (see below)This was not caught by functional tests as they send fully formed JSON messages and do not require JSON client interpretation, which both
dash-cliand Dash Qt require, this pull request adds additional handling to ensure that arrays and objects are interpreted if they are likely to be so (starting and ending with curly or square brackets) or otherwise passed as-is as a string.What this pull request isn't is full fledged conversion support for composite RPC arguments to other non-string types like integers, the scope here is specifically to allow for the backwards compatibility logic for
coreP2PAddrs,platformHTTPSAddrsorplatformP2PAddrsto work as intended.With this pull request, the following result is expected (see below)
Breaking Changes
None expected.
Checklist