Skip to content

Map engine Configuration errors to 400 (detect-but-never-redact) - #254

Merged
martsokha merged 1 commit into
mainfrom
fix/detect-only-policy-400
Aug 29, 2026
Merged

Map engine Configuration errors to 400 (detect-but-never-redact)#254
martsokha merged 1 commit into
mainfrom
fix/detect-only-policy-400

Conversation

@martsokha

@martsokha martsokha commented Aug 29, 2026

Copy link
Copy Markdown
Member

Summary

Pulls elide-runtime (with #421), which now rejects a request or policy set that can detect but never redact — the exact misconfiguration that previously produced a successful but byte-identical "redaction" (the redacted file equalled the input). The engine now raises a Configuration error naming the cause instead of silently returning a document that only looks processed.

On our side, the engine-error conversion mapped only MalformedInput to a client error and everything else — including Configuration — to a 500. So the new rejection would have surfaced as an opaque "Redaction engine failed" (500). This maps EngineErrorKind::Configuration to a 400 with a clear message, so that rejection (and other caller-supplied incoherence, e.g. a reviewer override naming an off-pipeline policy) reads as a client error the user can fix.

Why this matters

This closes the loop on the "redacted file is identical to the original" bug: the root cause was policies with detection scope but no matching redaction operator (our shipped templates covered only the text modality). It is now caught upstream and reported correctly as a 400 end-to-end, rather than shipping a deceptive clean-looking file.

Verification

Full gate green: cargo check, clippy -D warnings, fmt --check, doc -D warnings, cargo test --lib. Lockfile bump + a one-branch change in engine_error.rs; no other source changes were required.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Pipeline configuration errors are now reported as a 400 Bad Request instead of an internal server error.
    • Error messages more clearly indicate when request policies cannot process the submitted request.

Pull elide-runtime, which now rejects a request or policy set that can detect
but never redact — the misconfiguration that previously returned a successful,
byte-identical "redaction" (the redacted file equalled the input). The engine
raises a Configuration error naming the cause.

Map EngineErrorKind::Configuration to a 400 in the engine-error conversion, so
that rejection (and other caller-supplied incoherence, like a reviewer override
naming an off-pipeline policy) surfaces as a client error the user can fix rather
than an opaque "Redaction engine failed" 500.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018bKk1YEG4tZ69jzYVQvQL8
@martsokha martsokha added bug something isn't working as intended server API handlers, middleware, auth dependencies dependency updates and version bumps labels Aug 29, 2026
@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ddbded90-9ac0-4680-9530-2742a564e21a

📥 Commits

Reviewing files that changed from the base of the PR and between d5546c9 and 2cabacd.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • crates/nvisy-server/src/handler/error/engine_error.rs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The server now maps EngineErrorKind::Configuration to a 400 Bad Request with a specific message. The module documentation classifies configuration errors as caller errors.

Changes

Engine Error Mapping

Layer / File(s) Summary
Map configuration errors to Bad Request
crates/nvisy-server/src/handler/error/engine_error.rs
The conversion maps Configuration errors to BadRequest with the message “The pipeline's policies cannot process this request” and preserves the engine error as context. The module documentation describes Configuration errors as caller errors.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 2caba

The change reports caller-correctable pipeline configuration failures as HTTP 400 instead of HTTP 500, with no actionable merge-blocking risk remaining after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the primary change: mapping engine configuration errors to HTTP 400. The parenthetical specifies the detect-but-never-redact case covered by the change.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/detect-only-policy-400

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@martsokha
martsokha merged commit 06e5d93 into main Aug 29, 2026
9 checks passed
@martsokha
martsokha deleted the fix/detect-only-policy-400 branch August 29, 2026 16:52
@martsokha martsokha self-assigned this Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug something isn't working as intended dependencies dependency updates and version bumps server API handlers, middleware, auth

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant