Repository navigation
fix(platform): answer query request errors with INVALID_ARGUMENT - #5333
Conversation
About twenty query endpoints answered a request with an empty id list or a limit of 0 with gRPC UNKNOWN or INTERNAL. Clients take those for node faults, ban the node and send the request to the next one, so a few such calls banned every node. Each handler now refuses those requests itself, with INVALID_ARGUMENT, in both proof modes: - empty id lists: data contracts, identities balances, identities contract keys (ids or purposes), identity keys (specific keys or search purposes), evonode blocks by ids, identity and identities token balances and infos, token statuses, addresses infos; - a limit or count of 0: identity keys, evonode blocks by range, contract history (and above its maximum of 10), protocol upgrade vote status, epochs info, identity votes, pre-programmed distributions, group infos, group actions; - an addresses branch depth outside the allowed range, and an unproved key search without a limit. Handlers that rejected a limit by returning a Drive query error through `?` now return a validation error, and the service answers any Drive query syntax error with INVALID_ARGUMENT. A composite page with `$id IN` over 100 values, or over values that are not identifiers, is refused like the plain query instead of reporting corrupted code execution. Status messages are cut at 1024 bytes, so an error echoing an oversized document type name no longer exceeds HTTP/2 header limits. Queries are not consensus: no block execution path changes and proof contents are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 58 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
⛔ Files ignored due to path filters (1)
📒 Files selected for processing (27)
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 |
|
Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. Wait for the missing reviews, or a writer can post |
|
🔍 Review in progress — actively reviewing now (commit 6611c21) · triage: normal |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Verified both supplied findings against head 994d5c7: the empty-search validation misses searches containing only empty nested maps, and the status-message bound comment incorrectly describes a prefix limit as a total-message limit. Both are non-blocking; no blocking findings were supplied or confirmed. Validation was static only; the supplied CI snapshot reports successful Rust workspace tests and Swift/Kotlin checks, with PR Hygiene pending.
🟡 1 suggestion(s) | 💬 1 nitpick(s)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.1-sol(effort low) — The cross-cutting query validation and gRPC error-mapping changes span many endpoints but do not themselves change consensus, funds movement, cryptography, key handling, network deserialization, or storage migrations. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity below 15% reserve: weekly 15% left, 5h 100% left),glm-5.3-flash(not used above high effort; tier asks max) - Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `packages/rs-drive-abci/src/query/identity_based_queries/keys/v0/mod.rs`:
- [SUGGESTION] packages/rs-drive-abci/src/query/identity_based_queries/keys/v0/mod.rs:69-73: Validate that a search contains at least one purpose/security-level pair
The new guard rejects an empty outer map but accepts an equivalent empty search such as `purpose_map = { AUTHENTICATION: SecurityLevelMap { security_level_map: {} } }`. `IdentityKeysRequest::construct_search_query` skips every purpose whose nested map is empty, so this request produces the same empty GroveDB query that the new validation intends to refuse. With an explicit positive limit, it also bypasses the separate unproved-search limit check. Reject searches when all nested maps are empty, and cover this representation in both proof modes with a positive limit. A mixed map containing empty and nonempty entries should remain accepted.
In `packages/rs-drive-abci/src/query/service.rs`:
- [NITPICK] packages/rs-drive-abci/src/query/service.rs:87-91: Describe the status-message bound as a prefix limit
`bounded_message` keeps up to 1024 bytes and then appends `... (N bytes truncated)`, so the final message exceeds `MAX_STATUS_MESSAGE_BYTES`. This behavior is explicitly documented in the PR description and reflected in the test's `MAX_STATUS_MESSAGE_BYTES + 64` assertion; it is not a functional defect. Correct the constant's comment so future callers do not mistake it for a total-message size guarantee.
…ific keys Refuse only what fails today, as #5331 does: an empty id list, an identity keys limit of 0 and an epochs count of 0 are refused only when a proof is asked, since GroveDB cannot prove an empty query. Without a proof they keep their empty answer. Empty specific key ids and an empty key search, which both proof modes already answer, are no longer refused. An unproved specific-keys request whose limit is below its number of ids failed inside GroveDB with an internal error. The handler now fetches every requested id and keeps the first `limit` keys that exist, in id order: the keys the proof with that limit proves. Ported from #5331: an end-to-end test through the real `QueryService` and `DapiClient`, which checks every changed request in both proof modes, that three empty contract proof requests leave all 13 nodes available, and that a node fault still bans the node; and a book section on how query errors reach clients. The test calls the service in-process, so `rs-dapi-client` is its only new dev-dependency. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
📖 Book Preview built successfully. Download the preview from the workflow artifacts. Updated at 2026-10-08T15:59:57.010Z |
|
Waiting for bot review — coderabbitai not yet · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
Nodes now answer an empty id list without a proof with an empty result, as they always did, and refuse only a proof of it (#5333). The client follows: `names_nothing` holds only for a proved request, with the node's message, and the identity keys request has no entry, since nodes answer empty specific key ids and an empty key search in both proof modes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Verified the complete diff at head 457299a and found no blocking correctness or consensus-safety issues. One documentation nit remains; the empty-search validation recommendation is withdrawn, and the proposed Drive helper is outside this PR's required scope. Validation was static only: Rust workspace tests and PR Hygiene remained pending in the supplied CI snapshot taken at 2026-10-08T14:43:51Z.
💬 1 nitpick(s)
1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.1-sol(effort low) — The change is broad and alters query validation, error mapping, and response handling, but does not itself change consensus, funds movement, cryptography, key handling, network deserialization, or storage migrations. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity below 15% reserve: weekly 15% left, 5h 100% left),glm-5.3-flash(not used above high effort; tier asks max) - Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `packages/rs-drive-abci/src/query/service.rs`:
- [NITPICK] packages/rs-drive-abci/src/query/service.rs:87-91: Describe the status-message bound as a prefix limit
(existing thread: https://github.com/dashpay/platform/pull/5333#discussion_r4219442949)
MAX_STATUS_MESSAGE_BYTES bounds the retained prefix, not the complete status message: bounded_message truncates at a UTF-8 boundary and then appends `... (N bytes truncated)` at lines 1208–1210. The PR example correctly describes this as "1024 bytes plus the note," and the regression tests permit the additional suffix. Align this comment and the book's message-cap explanation with that distinction so future header-budget calculations do not treat 1024 bytes as a strict total-message maximum. No truncation behavior needs to change.
Out-of-scope follow-up suggestions (3)
These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.
- Pre-existing query synchronization loop can retain blocking workers indefinitely — In packages/rs-drive-abci/src/query/service.rs:147–165, counter is reset inside every polling iteration, so the intended 100-iteration timeout cannot fire. If the committed height advances beyond the captured platform-state snapshot, the loop neither refreshes that snapshot nor exits, retaining a blocking worker indefinitely. The same implementation exists at base ad63a48 and is not worsened by this PR, but the query-service availability impact warrants separate tracking.
- Follow-up: Track a separate issue or maintainer-requested PR to bound the synchronization wait, reload the state snapshot after a mismatch, and cover a height advance between snapshot acquisition and the guard check with a deterministic regression test.
- Centralize limited existing-key retrieval in Drive — Out of scope — the direct generic Drive fetch passes the original limit to the optional-result query at both base and head; this PR does not introduce that native-caller constraint. The handler's distinct-ID bound makes fetch-all-then-truncate bounded, SerializedKeyVec filters absent keys before truncation, and the new regression test compares the result with the limited proof. Adding a separate query-facing Drive API is an adjacent ownership redesign, not required for the stated gRPC repair; leaving the shared consensus-used fetch implementation unchanged is appropriate.
- Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.
- Own limited specific-key fetching in Drive — Out of scope — this overlaps the proposed Drive-helper redesign above. The existing generic optional-result fetch contract is unchanged, while the RPC adapter safely expands its bounded storage-fetch limit and applies the requested response cap. No incorrect endpoint result, dependency inversion, or newly broken native API was established.
- Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.
|
Bots are done — your move: post |
The note about dropped bytes is appended after the 1024 kept bytes, so the constant bounds the prefix, not the whole message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Waiting for bot review — coderabbitai not yet · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
Basic explanation
What this does: Some requests to a Platform node can't be answered, for example "prove these 0 data contracts" or "give me the next 0 group actions". About 20 query endpoints answered them with "unknown error" or "internal error". The node now answers "invalid request" (gRPC
INVALID_ARGUMENT) instead. A request that already got a real answer, even an empty one, keeps getting it. Two smaller fixes come along: error messages are capped at 1 KB, and a keys request that used to fail now gets its answer.Value: SDKs read "unknown" and "internal" as a broken node. They stop using that node for a while (a "ban") and send the request to the next node, which answers the same way. On the sakura devnet, three
contracts.getMany([])calls from evo-sdk banned all 13 nodes for at least 61 seconds. "Invalid request" is final for the SDKs: no ban, no retry on another node. A new end-to-end test shows all 13 nodes staying available.Risks: Low. Queries are not consensus: no block execution code changes, and the proofs of the requests that are still served do not change. No request that got an answer before is refused now. Error messages over 1024 bytes are cut, with a note saying how many bytes were dropped.
Issue being fixed or feature implemented
The 5.0.0-beta.2 adversarial QA on devnet sakura found that limit 0 or an empty id list made about 15 endpoints answer UNKNOWN or INTERNAL, and that the SDK then banned every node.
query_error_into_statusturned everyQueryErroroutside five variants intoStatus::unknown, anderror_into_statusturned every handlerErrintoStatus::internal, including Drive's own query syntax errors.The same report listed lower findings with the same cause, fixed here as well:
$id INover 100 values answered INTERNAL "corrupted code execution", while the plain query answeredINVALID_ARGUMENT;grpc-messageHTTP/2 header, which peers refuse past a few kilobytes, so the client saw INTERNAL.#5331 fixes the same finding with checks in the gRPC methods. This PR takes three things from it: the rule to refuse only what fails today, its end-to-end test, and its book section. On top of that it covers the cases #5331 leaves as INTERNAL, including one #5331 documents as a known residual. The client side, which also protects against nodes older than this fix, is #5334.
What was done?
Two rules for the handlers (
packages/rs-drive-abci/src/query/**/v0/mod.rs):Each handler checks the request before Drive sees it and refuses with a validation error, never with
?:getDataContractsids: []INVALID_ARGUMENTgetIdentitiesBalancesids: []INVALID_ARGUMENTgetIdentitiesContractKeysINVALID_ARGUMENTgetEvonodesProposedEpochBlocksByIdsids: []INVALID_ARGUMENTgetIdentityTokenBalances,getIdentityTokenInfostoken_ids: []INVALID_ARGUMENTgetIdentitiesTokenBalances,getIdentitiesTokenInfosidentity_ids: []INVALID_ARGUMENTgetTokenStatusestoken_ids: []INVALID_ARGUMENTgetAddressesInfosaddresses: []INVALID_ARGUMENTgetIdentityKeyslimit: 0INVALID_ARGUMENTgetEpochsInfocount: 0INVALID_ARGUMENTgetIdentityKeyslimitbelow the number of idsgetIdentityKeysINVALID_ARGUMENT/ OKgetDataContractHistorylimit: 0, or over 10INVALID_ARGUMENTgetProtocolVersionUpgradeVoteStatuscount: 0INVALID_ARGUMENTgetEvonodesProposedEpochBlocksByRangelimit: 0INVALID_ARGUMENTgetContestedResourceIdentityVoteslimit: 0INVALID_ARGUMENTgetTokenPreProgrammedDistributionslimit: 0INVALID_ARGUMENTgetGroupInfos,getGroupActionscount: 0INVALID_ARGUMENTgetAddressesBranchState[6, 9]INVALID_ARGUMENTDetails:
limitkeys that exist, in id order. Those are the keys the proof with that limit proves: ids[9, 0, 7, 3]with limit 2 return keys 0 and 3 in both modes.?as a Drive error. They now return it as a validation error naming the bound:limit 0 out of bounds of [1, 100]instead oflimit greater than max limit 100.u32, so263is no longer read as263 as u8 = 7.getEpochsInfousessaturating_addforstart_epoch + count.Status mapping (
packages/rs-drive-abci/src/query/service.rs)INVALID_ARGUMENTwherever it surfaces: returned by a handler (was INTERNAL) or reported asQueryError::Drive(was UNKNOWN). That also covers a document query whose clauses fail to parse.... (N bytes truncated).query_result_into_responseis the one path from a handler result to a response or status, used by the service and by the tests.Composite pages (
packages/rs-drive/src/query/composite_document_query/mod.rs):page_idsturns a bad$id INor$id ==value into the plain query path's syntax errors instead ofCorruptedCodeExecution.Book:
book/src/error-handling/drive-errors.mdgains "Query errors on the wire": how statuses reach clients, the mapping, the two rules and the table above.Examples:
Not changed:
getDocumentsv0limit: 0andgetShieldedEncryptedNotescount: 0keep their documented meaning (the default, the maximum). Empty specific key ids and an empty key search are still answered in both modes.getPathElementswith no keys is still answered.In-place changes to shipped generations
v0gRPC query handlers listed above, selected by every protocol version that serves them, andCompositeDocumentQuery::page_ids(protocol version 14).How Has This Been Tested?
packages/rs-drive-abci/tests/query_request_errors.rs(ported from fix(drive-abci): classify invalid query requests without banning nodes #5331), against the realQueryServiceover a fresh state:DapiClientover 13 nodes: each reaches one node, getsINVALID_ARGUMENT, and bans none;The test calls the service in-process instead of over an in-memory gRPC server, so
rs-dapi-clientis its only new dev-dependency. Run against the base branch's query code, the first two fail with exactly the "Before" column; the node-fault control passes either way.Per-handler tests: each fixed handler has a
should_refuse_…_as_invalid_argumenttest in itsv0module. They assert throughassert_invalid_argument_status, which uses the service's ownquery_result_into_response, and check that the unproved request still gets its answer.should_cap_an_unproved_specific_keys_request_like_its_proofcompares the unproved keys with the keys the limited proof verifies to, for five id lists and limits.Existing tests: those that pinned the old answers (
Err(Drive(Query(InvalidLimit))),is_err()) are rewritten.test_branch_state_no_checkpoint_returns_errorhad only passed because its depth was out of range; it now uses a valid depth, so it tests the missing checkpoint.service.rs: syntax errors from Drive map toINVALID_ARGUMENT; node faults and undecodable requests keep their codes; a message is cut at a character boundary; an oversized document type name comes back bounded, end to end.composite.rs:should_refuse_a_malformed_by_ids_page_as_invalid_argument.Commands:
cargo test -p drive-abci --lib query::: 791 passedcargo test -p drive-abci --test query_request_errors: 3 passedcargo test -p drive composite: 43 passedcargo clippy -p drive-abci -p drive --all-features --all-targets -- -D warningscargo check -p drive --no-default-features --features verifycargo fmt --allBreaking Changes
None. Requests that failed before get
INVALID_ARGUMENT(or, for keys under a limit, their answer); requests that were answered keep their answer.Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestFor repository code-owners and collaborators only
🤖 Generated with Claude Code
PR Hygiene ·
6611c21/skip-botsproceeds without the ones not yet reported/self-reviewedWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.