refactor: improve error message in schema validation exception#2902
refactor: improve error message in schema validation exception#2902christiangoerdes merged 2 commits intomasterfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughUpdated ValidatorInterceptor to improve error reporting during validator initialization by appending the caught exception message to the thrown ConfigurationException; imports were tightened from wildcards to explicit imports without functional behavior changes. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
core/src/main/java/com/predic8/membrane/core/interceptor/schemavalidation/ValidatorInterceptor.java (1)
96-96: Avoidnullin the refactored error message.
e.getMessage()may be null; this can degrade the new diagnostic text to...: null. Consider a null-safe fallback.Proposed null-safe tweak
- throw new ConfigurationException("Cannot create message validator: " + e.getMessage(), e); + var reason = (e.getMessage() == null || e.getMessage().isBlank()) ? e.getClass().getSimpleName() : e.getMessage(); + throw new ConfigurationException("Cannot create message validator: " + reason, e);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@core/src/main/java/com/predic8/membrane/core/interceptor/schemavalidation/ValidatorInterceptor.java` at line 96, The thrown ConfigurationException uses e.getMessage() which may be null; update the throw in ValidatorInterceptor (the "Cannot create message validator" exception) to use a null-safe message—e.g., include the exception class and a fallback for the message (Objects.toString(e.getMessage(), "no message") or e.getClass().getName() + ": " + Objects.toString(e.getMessage(), "no message")) so the resulting diagnostic never contains "null" and always provides useful context.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@core/src/main/java/com/predic8/membrane/core/interceptor/schemavalidation/ValidatorInterceptor.java`:
- Line 96: The thrown ConfigurationException uses e.getMessage() which may be
null; update the throw in ValidatorInterceptor (the "Cannot create message
validator" exception) to use a null-safe message—e.g., include the exception
class and a fallback for the message (Objects.toString(e.getMessage(), "no
message") or e.getClass().getName() + ": " + Objects.toString(e.getMessage(),
"no message")) so the resulting diagnostic never contains "null" and always
provides useful context.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 5371cf72-9ebb-4fd6-9e25-99e2a9003edd
📒 Files selected for processing (1)
core/src/main/java/com/predic8/membrane/core/interceptor/schemavalidation/ValidatorInterceptor.java
|
This pull request needs "/ok-to-test" from an authorized committer. |
|
/ok-to-test |
Summary by CodeRabbit