fix(cli): parse Windows snapshot mappings#9723
Conversation
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/snapshots.rs`:
- Around line 22-40: The parsing in from_cli_arg currently treats the last colon
as the separator, so a Windows drive-letter colon can be mistaken for the
snapshot/name boundary. Update from_cli_arg in src/snapshots.rs to explicitly
validate the split result by rejecting path-like collection_name values (for
example, ones containing path separators or otherwise looking like a filesystem
path), so malformed inputs without a real ":collection_name" suffix still
trigger the intended missing-collection panic instead of producing a bogus
path/name pair.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 71e0e4b0-fd9f-48ec-835a-8cb5af1c01fd
📒 Files selected for processing (1)
src/snapshots.rs
Parse CLI snapshot mappings from the final colon so Windows drive-letter paths keep their drive prefix. Keep full-snapshot recovery on typed mappings instead of formatting paths back into the CLI string protocol. Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
Reject path-like collection names when parsing CLI snapshot mappings so a Windows path without a target collection suffix reports the intended missing-collection error instead of producing a bogus mapping. Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
d382e7e to
a561491
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis change introduces a Estimated code review effort: 2 (Simple) | ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
timvisee
left a comment
There was a problem hiding this comment.
Thanks, this makes sense. I agree that splitting at the last : is a good idea.
I've merged some tests on your branch and rebased on the latest dev to make tests pass.
Windows probably is not where most people deploy Qdrant, so I see this as a small edge case rather than an urgent production issue. I opened the PR because the CLI already accepts
PATH:NAME, and valid Windows drive-letter paths currently do not fit that parser. I think either accepting or declining this PR would be reasonable, or it can at least serve as an issue to discuss this edge case.All Submissions:
devbranch (notmaster) and my branch was created fromdev.Changes to Core Features:
What changed
What Problem This Solves
CLI snapshot recovery accepts mappings in the documented
<snapshot_file_path>:<target_collection_name>shape. That convention is straightforward for POSIX paths such as/tmp/collection.snapshot:test_collectionand for relative paths such ascollection.snapshot:test_collection, because the only colon is the separator between the snapshot path and the target collection name.Windows absolute paths are different. A valid Windows path can contain a drive-letter prefix, so a normal mapping can look like this:
In that string, the first colon belongs to the path itself (
C:), while the final colon is the actual mapping separator beforetest_collection.Before this change,
recover_snapshots()usedsplit(':'), which treats every colon as a separator. For the Windows example above, the parser did not see one path and one collection name. It saw three pieces instead:That means
Cwas incorrectly treated as the snapshot path,\tmp\collection.snapshotwas incorrectly treated as the collection name, andtest_collectionbecame an unexpected third part. Because of that third part, the parser rejected the mapping withToo many parts in snapshot mappingbefore snapshot recovery could start.So the issue is not that the Windows path is invalid. The path is valid, but the CLI mapping parser consumes the drive-letter colon as if it were part of the
PATH:NAMEprotocol. This makes a valid Windows snapshot path impossible to express through the documented CLI mapping format.Changes
This PR moves snapshot mapping parsing into a small internal
SnapshotMappingtype and parses CLI mappings from the final colon. Earlier colons stay with the snapshot path, so Windows drive-letter paths keep their drive prefix while the documentedPATH:NAMEshape remains unchanged.It also avoids the same string-protocol round trip in full-storage snapshot recovery.
recover_full_snapshot()already reads structured snapshot configuration, so it now buildsSnapshotMappingvalues directly instead of formatting unpacked snapshot paths back intoPATH:NAMEstrings and parsing them again.Evidence
The focused tests cover the old failing shape and the nearby parser boundaries:
Before this change, that mapping could be split into
C,\tmp\collection.snapshot, andtest_collection, which hitToo many parts in snapshot mapping. After this change, the parser returns:The test suite also covers POSIX absolute paths, relative paths, paths with earlier colons, missing separators, empty paths, and empty collection names.
Possible call chain / impact
This only changes startup CLI snapshot mapping parsing and the internal full-storage snapshot mapping handoff. It does not change CLI flag names, collection restore behavior after parsing, REST/gRPC snapshot recovery APIs, or snapshot storage formats.
Scope
Affected:
--snapshot PATH:NAME--collection-snapshot PATH:NAMEUnchanged:
PATH:NAMEshapeValidation
cargo +nightly fmt --all --checkgit diff --checkcargo test -p qdrant snapshot_mapping -- --nocaptureFocused test result:
AI disclosure
Commit
97dd739c497f200e8be92d198dca9ffa18a7055ewas prepared with AI assistance. Initial prompt intent: fix Qdrant CLI snapshot mapping parsing so Windows drive-letter paths are not split at the drive colon.