-
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 📥 CommitsReviewing files that changed from the base of the PR and between 50f669776955566f279ce2b56799c4a36c2c1825 and 5978985. 📒 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
fe1cff3 chore: bump release to 23.0.2 (pasta) a8f15c1 Merge #7032: fix: drop gsl usage from RebuildListFromBlock function wrapper (pasta) 736bb26 chore: bump manpages for 23.0.1 (pasta) d5c7d25 chore: bump nMinimumChainWork and defaultAssumeValid (pasta) 4f8aa71 chore: bump version to 23.0.1 (pasta) 0865b7c docs: add release notes for 23.0.1 (pasta) 2048b42 Merge #6986: test: new commandline argument -tinyblk to use blk size just 64kb instead 16Mb (pasta) 1a9b20c Merge #7013: fix: update BuildTestVectors call to adjust batch size based on output flag (pasta) 36e4679 Merge #7009: fix: include QDebug directly (pasta) 69d0c9c Merge #6999: feat: verify and repair evodb diffs automatically at node startup (pasta) ca16437 Merge #6996: perf: reduce cs_main lock scope in evodb verify/repair operations (pasta) 207526e Merge #6977: fix: bls benchmarks crash when ran independently (pasta) 226aaf4 Merge #6969: feat: add evodb verify and repair RPC commands (pasta) 92abe9b Merge #6964: perf: remove duplicated check of same key in the instant send database (pasta) 5a1ec4c Merge #6961: fix: correct BLS scheme setting in `MigrateLegacyDiffs()` when `nVersion` is present (pasta) bf653d3 Merge #6949: depends: Qt 5.15.18 (pasta) faf58cd merge bitcoin#30774: Qt 5.15.16 (Kittywhiskers Van Gogh) 6a995f5 Merge #6944: fix: HD chain encryption check ordering issue (pasta) 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) ebf3a64 docs: typos (pasta) 4ad5533 docs: typos (pasta) f407453 doc: Replace Bitcoin Core PR references with Dash Core backport PRs (pasta) 78d0725 docs: add note on proto bump and platformban p2p (pasta) e0519c3 docs: fix whitespace errors (pasta) bc8db22 docs: minor improvements to release notes (pasta) c338511 docs: reorganize rpc updates to organize extended address changes (thephez) 700c46e style: make heading style consistent (thephez) bd636bd docs: add contributors (pasta) 6d29bc3 docs: revert changes deferred to v24 (pasta) 615f5ff docs: make the downgrade warning more confident (pasta) 567771a Apply suggestions from code review (PastaPastaPasta) 2b3211a docs: add link to 22.1.3 release notes (pasta) 548a38a docs: remove individual release notes files (pasta) e770c25 docs: add v23.0.0 release notes and archive v22.1.3 (pasta) Pull request description: ## Issue being fixed or feature implemented Includes changes from 23.0.0 release too because we never merged it back. ## What was done? ## How Has This Been Tested? ## Breaking Changes ## Checklist: - [ ] 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 - [ ] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: PastaPastaPasta: utACK 491db4a kwvg: utACK 491db4a Tree-SHA512: 61895cd1f9d01ac7be1d407afe1ddd24b98e8242cb03229ecd586a4d2d1c43dbc62c98da52a8c715b3a5943fb40e99b23251e691f778779af9d6da94392122a3
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