Repository navigation
Conversation
Found while testing crates/engine/src/cmd/library.rs:736 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 ratings and test accepted values crates/engine/src/cmd/library.rs, crates/engine/src/tests.rs |
photo.rate rejects fractional ratings and values outside 0–5. Tests verify rejected values do not change the rating and that 5.0 and 3 are accepted. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Low
Suggested reviewers: aiongg
Merge Risk: 
Minimal · up to 50874
-
No actionable merge-blocking risk remains; the rating validation change is ready for normal checks.
Architecture risk: 
Low · up to 50874
-
The change affects 1 system.
Changed systems:
cratesArchitecture concerns
No architecture-level concerns identified.Review details
-
Systems and components
- observed — crates (service) was modified; 2 changed files map to changed impact.
Before / after behavior
- observed — Modified behavior in crates/engine/src/tests.rs: Adds coverage asserting fractional
photo.ratevalues are rejected without changing the rating, while5.0and integer3are accepted. - observed — Modified behavior in crates/engine/src/cmd/library.rs:
photo.ratereplaces floating-point parsing and integer truncation with integer parsing, accepting only values from 0 through 5 and returning a whole-number validation error otherwise.
-
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title "Reject fractional and out-of-range ratings in photo.rate" matches the main change. The raw summary and PR objectives both say photo.rate now rejects non-integer values (such as 5.9 and -0.9) and values outside 0 through 5, where it previously truncated them and accepted them. The title names the command, the affected inputs, and the behavior change. It is specific and concise, and it does not use vague terms.
-
-
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.
# Conflicts: # crates/engine/src/cmd/library.rs
|
Landed in #2814. Thank you for the contribution, @Silvertree2010! Main had since wrapped If you haven't already, come and join us on Discord: https://discord.gg/artcraft |
Found while testing
crates/engine/src/cmd/library.rs:736(no existing issue): photo.rate accepts fractional and out-of-range ratings by truncating them.Cause
photo.rate read
ratingas f64 and cast it withas i64, which truncates toward zero, before the 0..=5 range check. A value like 5.9 was stored as 5 and -0.9 as 0, where the command should have returned an error.Fix
photo.rate now reads
ratingwithindex_req, which rejects non-integral and negative numbers, and then checks that the result is at most 5. Fractional or out-of-range values now return a BadParams error. Whole numbers, including 5.0, are still accepted.Verified
tests::rating_rejects_fractional_values: fails onmainwithout the fix and passes with it (cargo test -p lightcraft-engine --lib rating_rejects_fractional_values).cargo xtask cipasses.Not changed
I did not change
index_reqorf64_req. A missingratingkey now reports 'rating must be a whole number 0..5' instead of 'missing numberrating'.🤖 Generated with AI by ApolloOffice, see the Co-Authored-By trailers for the models
Summary by CodeRabbit