Skip to content

refactor: improve error message in schema validation exception#2902

Merged
christiangoerdes merged 2 commits intomasterfrom
validator-error-message
Apr 10, 2026
Merged

refactor: improve error message in schema validation exception#2902
christiangoerdes merged 2 commits intomasterfrom
validator-error-message

Conversation

@predic8
Copy link
Copy Markdown
Member

@predic8 predic8 commented Apr 7, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved error messages during validator initialization to provide more detailed feedback for troubleshooting configuration issues. No functional changes to request/response handling or validation logic; existing validation behavior remains unchanged.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e3ae7d2a-8b16-4b6b-a48f-5f18e15c7ac5

📥 Commits

Reviewing files that changed from the base of the PR and between e6dba27 and ff393a1.

📒 Files selected for processing (1)
  • core/src/main/java/com/predic8/membrane/core/interceptor/schemavalidation/ValidatorInterceptor.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • core/src/main/java/com/predic8/membrane/core/interceptor/schemavalidation/ValidatorInterceptor.java

📝 Walkthrough

Walkthrough

Updated 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

Cohort / File(s) Summary
Import Optimization & Init Error Message
core/src/main/java/com/predic8/membrane/core/interceptor/schemavalidation/ValidatorInterceptor.java
Replaced wildcard imports with explicit imports and narrowed static imports. ValidatorInterceptor.init() now rethrows ConfigurationException with the original exception message appended via "Cannot create message validator: %s".formatted(e.getMessage()). No other functional changes to validation/request/response flow.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

I nibble at imports, neat and small, 🐇
I stitch one message to show it all,
No mystery left where errors hide,
Validators ready, hopping with pride,
A tidy patch — a gentle fall.

🚥 Pre-merge checks | ✅ 2 | ❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'refactor: improve error message in schema validation exception' accurately summarizes the main change: improving error messages in the ValidatorInterceptor's exception handling.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch validator-error-message

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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
core/src/main/java/com/predic8/membrane/core/interceptor/schemavalidation/ValidatorInterceptor.java (1)

96-96: Avoid null in 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

📥 Commits

Reviewing files that changed from the base of the PR and between cd97d5d and e6dba27.

📒 Files selected for processing (1)
  • core/src/main/java/com/predic8/membrane/core/interceptor/schemavalidation/ValidatorInterceptor.java

@membrane-ci-server
Copy link
Copy Markdown

This pull request needs "/ok-to-test" from an authorized committer.

@christiangoerdes
Copy link
Copy Markdown
Collaborator

/ok-to-test

@christiangoerdes christiangoerdes merged commit ea20871 into master Apr 10, 2026
5 checks passed
@christiangoerdes christiangoerdes deleted the validator-error-message branch April 10, 2026 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants