Repository navigation
Preserve validation details when rendering labels - #12874
SchrodingersGat merged 3 commits into
Conversation
Keep logging validation errors in both rendering wrappers before re-raising the original exception. LabelTemplate.print deletes failed DataOutput records, so the error log preserves the diagnostic after the result is removed. Update the mocked tests to require logging while retaining the original validation details.
✅ Deploy Preview for inventree-web-pui-preview canceled.
|
|
Have you tested and ensured that no internal information or secrets are leaked to unprivileged user through all possible error messages? |
Fair point. I did not consider ValidationError as dangerous in this respect. It is normally user-facing problem. My personal/developer-centric opinion is that its value outweighs negatives. AI analysis: • Current built-in validation messages can include internal details and raw template values:
Other messages are fixed descriptions, such as missing QR-code data or an invalid model argument. I haven’t identified an explicit credential disclosure in these inspected messages, but operands or paths could contain information the printing user should not see. ValidationError does not guarantee a sanitized message. |
|
Sorry, fixed now, using extra commit; should I add new commits or force-push in future?
I'll adapt as requested. GPT is generating the tests, I just verify that they make sense and do not test that 1+1 is still 2. With AI tools, it is usually better to have more tests to avoid missing something. In this concrete case the tests are pretty cheap, so more code to review is probably bigger problem. But I did not test other PRS yet, it may be worse. AI: Measured both added tests locally, including discovery, class/test setup and teardown, plugin construction, mocks, and assertions:
Running them as a standalone Django command took 4.57 seconds median across five fresh processes, including startup and shutdown. That startup cost is already paid when they run inside the existing suite. They require no database setup, fixtures, or actual rendering. Estimated incremental suite cost is therefore approximately 6–15 ms locally. |
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project check has failed because the head coverage (88.17%) is below the target coverage (92.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #12874 +/- ##
==========================================
- Coverage 87.26% 86.79% -0.47%
==========================================
Files 1502 1502
Lines 102169 103017 +848
Branches 11661 11661
==========================================
+ Hits 89156 89416 +260
- Misses 12948 13536 +588
Partials 65 65
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Happy with this overall, thanks for the implementation @ledvinap |
Label rendering wrappers currently replace all exceptions with generic “Error rendering label to PDF/HTML” messages, losing useful validation details raised by upstream template tags or plugins.
Handle
ValidationErrorseparately in both wrappers and re-raise it unchanged. Preserve existing logging, including for validation failures, so diagnostics remain available after failedDataOutputrecords are deleted. Unexpected exceptions retain their existing generic messages.This fix applies independently to master. Together with #12872, the specific validation details are also retained in failed results and logging can be removed.
Mocked tests cover validation-detail preservation, logging, and unchanged handling of unexpected exceptions in both wrappers. Focused tests, Ruff checks, and
git diff --checkpass; the full suite was not run.