Repository navigation
fix(query): refuse an overlong path segment in a ranged aggregate sum query - #1044
Conversation
… query query_aggregate_sums with a range query item opened the storage context for the caller's path without checking its segment lengths, so a segment longer than 255 bytes panicked in storage prefix construction. The key branch of the same walk and the other path-building calls already return InvalidInput for such a path (#680, #1006); the range branch of the aggregate sum walk was the one site left. Call validate_path_segment_lengths just before the prefix is built, as the range branch of the regular query walk does. Not version-gated: the refused call used to panic. The overlong segment table gains a ranged query_aggregate_sums call, run at GROVE_V1, GROVE_V3 and latest with the segment alone, last, first and in the middle. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Waiting for bot review — coderabbitai ✓ · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
✅ Final review complete — no blockers (commit bde9d54) · triage: low · Phase 2 only (no Phase 1 for this repository) |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 2 only (no Phase 1 for this repository)
The change validates aggregate-sum range-query paths before constructing the transactional storage context, preventing the overlong-segment panic while preserving existing behavior for valid inputs. The shared validator, cost-preserving error propagation, version handling, and regression coverage are appropriate; CI code checks are still queued with no reported failures.
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.1-sol(effort low) — This is a small, well-contained validation fix in an existing query path with focused regression coverage and no changes to stored data, cryptography, or consensus behavior. - Phase 1 reviewers: not run (disabled for this repository)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort medium); agentphase2-reviewer
|
Bots are done — your move: post |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1044 +/- ##
===========================================
- Coverage 93.32% 93.21% -0.11%
===========================================
Files 366 366
Lines 112843 112253 -590
===========================================
- Hits 105308 104642 -666
- Misses 7535 7611 +76
🚀 New features to boost your workflow:
|
CI installs the floating stable toolchain, which is now Rust 1.100. Its
clippy reports needless_bool for `if cond { return true; } false` in
Query::has_subquery, and the Linting job denies warnings, so every pull
request fails there. Return the condition itself; behaviour is unchanged.
Checked with `cargo +1.100.0 clippy --workspace --exclude grovedb-bincode
--exclude grovedb-bincode-derive --all-features --no-deps -- -D warnings`,
which reports nothing else in the workspace.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Waiting for bot review — coderabbitai ✓ · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)
The PR correctly adds path-segment validation immediately before the aggregate-sum range query constructs a storage context, converting the prior overlong-segment panic into the established InvalidInput error. The boolean simplification is behaviorally equivalent, regression coverage exercises the relevant path shapes and versions, and all code-related CI checks succeeded.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.1-sol(effort low) — This is a small, well-contained validation fix in an existing query path with focused regression coverage and no critical-surface changes. - Phase 1 reviewers: not run (disabled for this repository)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort medium); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
|
Bots are done — your move: post |
Basic explanation
What this does:
query_aggregate_sumsadds up sum items along a query until a sum limit is reached. When the query item was a range and the caller's path had a segment longer than 255 bytes, the call panicked. It now returns an error, as the same call with a key query item already does.Value: A caller who passes a bad path gets
InvalidInputback instead of a crashed process.Risks: Very low. One check is added before a storage call that could only panic for the paths the check refuses. No stored data, hash or cost changes.
Issue being fixed or feature implemented
Storage records each path segment length in one byte when it builds a subtree prefix, so a path with a segment longer than 255 bytes panics there. #1006 (for #680) added
validate_path_segment_lengthsjust before each place where a caller's path first reaches prefix construction. The aggregate sum walk has its own copy of the query walk, and its range branch was not covered: it callsget_transactional_storage_contexton the caller's path directly.Keys are capped at 255 bytes on insert, so no subtree has such a path. Only a caller passing one by mistake reaches this.
What was done?
aggregate_sum_query_itemingrovedb/src/element/aggregate_sum_query/mod.rscallsvalidate_path_segment_lengthsat the start of its range branch, the same line the range branch of the regular query walk has ingrovedb/src/element/query.rs.Before and after
resultstorage/src/rocksdb_storage/storage.rs("path segment length must not exceed 255 bytes")Err(Error::InvalidInput("path segment length must be at most 255 bytes"))Unchanged: the same call with a key query item (
AggregateSumPathQuery::new_single_key) returned this error before and still does.Public interface
No signature changes.
GroveDb::query_aggregate_sumsandGroveDb::query_aggregate_sums_with_optionsreturnError::InvalidInputfor a range query over a path with a segment longer than 255 bytes, where they panicked before. Every other input gives the same result as before.How Has This Been Tested?
grovedb/src/tests/overlong_path_segment_tests.rsgains the entryquery_aggregate_sums over a rangein the table of path-building calls. The table runs each call atGROVE_V1,GROVE_V3and the latest grove version, with the overlong segment as the whole path, last under an existing tree, first in a longer path, and in the middle of one. Without the fixevery_path_building_call_refuses_an_overlong_segmentfails with the storage panic; with it the test passes.Run locally:
cargo test -p grovedb --lib overlong_path_segment(5 passed)cargo test -p grovedb --lib aggregate_sum(149 passed)cargo fmt --all -- --checkBreaking Changes
None.
Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code
PR Hygiene ·
bde9d54/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.Summary by CodeRabbit