Repository navigation
Conversation
Found while testing crates/engine/src/cmd/modify/transform.rs:69 (run_copy) Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Validate and test copy counts crates/engine/src/cmd/modify/transform.rs, crates/engine/tests/it/copy_count.rs, crates/engine/tests/it/main.rs |
run_copy rejects invalid supplied counts instead of defaulting or clamping them. The integration test checks that invalid counts do not change the entity count and that a count of three adds three entities. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Possibly related PRs
- storytold/cadcraft#2220: Moves
run_copyand retains the 1–10,000 count handling that this change updates. - storytold/cadcraft#2239: Includes the clamping behavior that this change replaces with rejection of invalid supplied counts.
Suggested reviewers: aiongg
Merge Risk: 
Minimal · up to b7a5b
-
The copy-count change is ready to merge after normal checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title "Refuse invalid count in JSON copy instead of clamping it" matches the main change. The raw summary says run_copy now rejects invalid count values with an error instead of defaulting or clamping them. The objectives confirm the same intent, and the summary lists the added integration test for copy count handling. The title is specific and concise, and it names the behavior change and the affected command.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 3 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
|
@Silvertree2010, thanks for this series (#2294, #2286, #2269, #2190, and #1252 for unknown keys). Refusing instead of clamping is exactly what agents need; see the error part of #1039. One thing these PRs can't do yet: tell a caller which parameter was wrong without parsing the message. I'd like to propose a small core, separate from your PRs. Would that fit how you're working through these? If yes, I'll open it as a small PR and leave the call sites to whoever touches them. |
austin62jake
left a comment
There was a problem hiding this comment.
Tested on Windows 10 Pro x64 (Rust 1.99.1, cargo-nextest 0.9.150), with this PR merged onto current main (336243e). It merges cleanly, and it works.
invalid_copy_count_is_refusedfails onmainand passes with the fix.cargo xtask cipasses all 7 steps (2621 tests) with this PR merged ontomaintogether with #2287, #2301, #2314 and #2335, which I tested at the same time, and #2198 so the gate runs on Windows.
One inconsistency to decide on: this refuses "count": null, and the test requires that. The array commands treat null as "use the default": ARRAYEDIT's count_param does, and so does #2399's count_or for ARRAYRECT and ARRAYPOLAR (None | Some(Value::Null) => Ok(default)). A client that sends null for "not given" would get 1 copy from COPY's default today and an error with this PR, while the array commands accept it. Matching them (None | Some(Value::Null) => 1) would make the JSON commands agree. Either way the error message is clear.
|
Landed — thank you @Silvertree2010 for this contribution to CADCraft! If you haven't already, come join us on Discord: https://discord.gg/artcraft |
Found while testing
crates/engine/src/cmd/modify/transform.rs:69 (run_copy)(no existing issue): JSON copy silently clamps an invalid count (0, negative, non-integer or over 10000) instead of refusing it.Cause
run_copy read
countwithas_u64().unwrap_or(1).clamp(1, 10_000). Zero, negative, non-integer and non-numeric counts silently became 1, and counts over 10000 silently became 10000. The command reported success with a drawing different from the one requested.Fix
run_copy now returns an invalid-parameters error (
countmust be an integer from 1 to 10000) whencountis present but not an integer in that range. A missingcountstill defaults to 1. A regression test covers 0, -3, 2.5, "abc", null, 10001 and 50000, checks the drawing is unchanged after each refusal, and checks that a valid count still copies.Verified
copy_count::invalid_copy_count_is_refused: fails onmainwithout the fix and passes with it (cargo test -p cadcraft-engine --test it copy_count).cargo xtask cipasses.Not changed
The interactive copy prompts and the other commands' parameter handling are unchanged.
🤖 Generated with AI by ApolloOffice, see the Co-Authored-By trailers for the models
Summary by CodeRabbit