Skip to content

Conversation

@predic8
Copy link
Member

@predic8 predic8 commented Jan 3, 2026

enhance: improve YAML parsing error handling with specific messages f…
…or missing classes and shorten output

Summary by CodeRabbit

  • Documentation
    • Updated MongoDB exchange store example: simplified setup using apis.yaml, clearer driver guidance, streamlined run/test steps, and updated Admin Console verification; includes sample apis.yaml for a MongoDB-backed store and example APIs.
  • Improvements
    • Enhanced parsing error diagnostics to give clearer, actionable messages when required components or dependencies are missing.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 3, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Adds explicit NoClassDefFoundError handling to YAML instantiation in GenericYamlParser, introduces a MongoDB-backed exchange-store example with an apis.yaml config and README updates, and appends two YAML-parsing items to the 7.X roadmap.

Changes

Cohort / File(s) Summary
YAML parser / Error handling
annot/src/main/java/com/predic8/membrane/annot/yaml/GenericYamlParser.java
Adds a dedicated NoClassDefFoundError catch in createAndPopulateNode to extract the missing class from the cause and throw/log a detailed ParsingException; placed before the generic Throwable catch. Also converts some imports to wildcard forms.
MongoDB exchange-store example
distribution/examples/extending-membrane/mongo-exchange-store/README.md, distribution/examples/extending-membrane/mongo-exchange-store/apis.yaml
Rewrites README to emphasize MongoDB persistence and apis.yaml setup; removes proxies.xml example; adds apis.yaml that defines components.my-store.mongoDBExchangeStore and two APIs (ports 2000 and 9000, one including adminConsole).
Roadmap
docs/ROADMAP.md
Adds 7.X items about moving YAML parsing to core and shortening parse error messages when the cause is clear; removes an outdated IfInterceptor entry.

Sequence Diagram(s)

(Skipped — changes are localized error handling, example configuration, and documentation; no new multi-component sequential control flow.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

7.x

Suggested reviewers

  • rrayst

Poem

🐰 I hop through YAML, light and quick,
I sniff missing classes, catch each trick.
Mongo jars keep exchanges safe and warm,
Roadmap seeds a clearer parsing form.
Hooray — a rabbit cheers this tiny fix.

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The pull request title 'MongoDB Exchange Store YAML Example' does not accurately represent the main changes. While MongoDB is mentioned, the primary objectives focus on improving YAML parsing error handling and shortening parser output, with MongoDB being secondary. Update the title to reflect the main change: 'Improve YAML parsing error handling for missing classes' or similar, as this is the primary objective stated in the commit/change summary.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c981cd8 and 8b96d5a.

📒 Files selected for processing (1)
  • docs/ROADMAP.md

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
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.

Actionable comments posted: 4

🧹 Nitpick comments (2)
annot/src/main/java/com/predic8/membrane/annot/yaml/GenericYamlParser.java (2)

193-205: Consider handling null message from cause.

If e.getCause().getMessage() returns null, the error message will contain "Missing class: null", which may be confusing. Consider falling back to the cause's class name or a default message.

Also, note the minor spacing inconsistency on line 201: throw new ParsingException(e,node); — add a space after the comma for consistency with the project's style.

🔎 Suggested improvement
         catch (NoClassDefFoundError e) {
             if (e.getCause() != null) {
-                var missingClass = e.getCause().getMessage(); // TODO: Better use ExceptionUtil.getRootCause() but it isn't visible in annot.
+                var cause = e.getCause();
+                var missingClass = cause.getMessage() != null ? cause.getMessage() : cause.getClass().getName();
                 var msg = "Could not create bean with class: %s\nMissing class: %s\nConfiguration: %s".formatted(clazz, missingClass, node);
                 log.error(msg);
                 throw new ParsingException(msg, node); // TODO: Cause we know the reason, shorten output.
             }
-            throw new ParsingException(e,node);
+            throw new ParsingException(e, node);
         }

196-199: TODO comments indicate deferred improvements.

The TODO comments here align with the roadmap item about shortening error messages. Consider creating issues to track these improvements:

  1. Refactoring to use ExceptionUtil.getRootCause() once it's accessible from the annot module
  2. Shortening the error output when the cause is known

Would you like me to open issues to track these TODO items?

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 24da0a0 and 62bc690.

📒 Files selected for processing (4)
  • annot/src/main/java/com/predic8/membrane/annot/yaml/GenericYamlParser.java
  • distribution/examples/extending-membrane/mongo-exchange-store/README.md
  • distribution/examples/extending-membrane/mongo-exchange-store/apis.yaml
  • docs/ROADMAP.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Automated tests
  • GitHub Check: Analyze (java)
🔇 Additional comments (2)
distribution/examples/extending-membrane/mongo-exchange-store/README.md (2)

3-4: LGTM!

The updated description clearly conveys the MongoDB persistence benefits and use cases.


23-23: LGTM!

The configuration step correctly references the new apis.yaml file, aligning with the YAML-first configuration approach.

Copy link
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.

Actionable comments posted: 1

♻️ Duplicate comments (1)
distribution/examples/extending-membrane/mongo-exchange-store/README.md (1)

20-23: Fix list indentation for proper Markdown formatting.

The nested list items on lines 20 and 23 are indented with 2 spaces but should start at column 0 for proper Markdown list formatting.

🔎 Proposed fix
 1. **Download MongoDB Driver:**
 
-  - Choose from:
-    [https://repo1.maven.org/maven2/org/mongodb/mongodb-driver-sync/](https://repo1.maven.org/maven2/org/mongodb/mongodb-driver-sync/)
-    a recent version. 5.X is recommended.
-  - Place it in the `lib` directory of your Membrane installation.
+- Choose from:
+  [https://repo1.maven.org/maven2/org/mongodb/mongodb-driver-sync/](https://repo1.maven.org/maven2/org/mongodb/mongodb-driver-sync/)
+  a recent version. 5.X is recommended.
+- Place it in the `lib` directory of your Membrane installation.
🧹 Nitpick comments (1)
distribution/examples/extending-membrane/mongo-exchange-store/README.md (1)

20-23: Consider adding MongoDB compatibility notes.

While the generic "5.X is recommended" approach is more maintainable than pinning to a specific version, consider adding:

  • Minimum MongoDB Server version requirement (driver 5.x requires Server ≥4.2)
  • Brief note about potential breaking changes when upgrading between 5.x versions
  • Optional: Maven/Gradle dependency snippets as an alternative to manual JAR downloads for easier dependency management

This would help users avoid compatibility issues and streamline setup.

📝 Example addition
  - Choose from:
    [https://repo1.maven.org/maven2/org/mongodb/mongodb-driver-sync/](https://repo1.maven.org/maven2/org/mongodb/mongodb-driver-sync/)
    a recent version. 5.X is recommended.
  - **Note:** MongoDB Java driver 5.x requires MongoDB Server ≥4.2. Review release notes for breaking changes between versions.
  - Place it in the `lib` directory of your Membrane installation.
  
  Alternatively, add to your `pom.xml`:
  ```xml
  <dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongodb-driver-sync</artifactId>
    <version>5.6.0</version>
  </dependency>

</details>

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used**: defaults

**Review profile**: CHILL

**Plan**: Pro

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 62bc690d51424973433e938636015bb0df6a5045 and f1276a7c9fbe83bca40a3cabdbbccba67bf9e0a0.

</details>

<details>
<summary>📒 Files selected for processing (2)</summary>

* `annot/src/main/java/com/predic8/membrane/annot/yaml/GenericYamlParser.java`
* `distribution/examples/extending-membrane/mongo-exchange-store/README.md`

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧠 Learnings (1)</summary>

<details>
<summary>📚 Learning: 2025-09-22T19:49:29.473Z</summary>

Learnt from: predic8
Repo: membrane/api-gateway PR: 2156
File: pom.xml:0-0
Timestamp: 2025-09-22T19:49:29.473Z
Learning: In the Membrane API Gateway project, jackson-annotations is pinned to version "2.20" instead of using ${jackson.version} (2.20.0) because version 2.20.0 is not available in Maven repository yet for jackson-annotations, while it is available for jackson-core and jackson-databind. This version inconsistency is intentional and necessary due to different release schedules between Jackson modules.


**Applied to files:**
- `annot/src/main/java/com/predic8/membrane/annot/yaml/GenericYamlParser.java`

</details>

</details><details>
<summary>🪛 markdownlint-cli2 (0.18.1)</summary>

<details>
<summary>distribution/examples/extending-membrane/mongo-exchange-store/README.md</summary>

20-20: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)

---

23-23: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)

</details>

</details>

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)</summary>

* GitHub Check: Analyze (java)

</details>

<details>
<summary>🔇 Additional comments (3)</summary><blockquote>

<details>
<summary>annot/src/main/java/com/predic8/membrane/annot/yaml/GenericYamlParser.java (1)</summary><blockquote>

`190-202`: **LGTM! Improved error messages for missing class dependencies.**

The specific `NoClassDefFoundError` handling provides clearer diagnostics when bean instantiation fails due to missing classes, which aligns well with the PR objective to improve YAML parsing error messages.

</blockquote></details>
<details>
<summary>distribution/examples/extending-membrane/mongo-exchange-store/README.md (2)</summary><blockquote>

`3-4`: **LGTM! Clear description of MongoDB-backed persistence.**

The updated description effectively communicates the value of persistent storage and post-restart inspection capabilities.

---

`25-25`: **LGTM! Shift to YAML configuration.**

The change from `proxies.xml` to `apis.yaml` aligns with the PR's YAML-driven configuration approach and the new `apis.yaml` file added to this example.

</blockquote></details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

@membrane-ci-server
Copy link

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

@predic8
Copy link
Member Author

predic8 commented Jan 3, 2026

/ok-to-test

predic8 added a commit that referenced this pull request Jan 4, 2026
- Added `apis.yaml` with OpenTelemetry plugin configuration for distributed tracing in Membrane.
- Improved `OpenTelemetryInterceptor` logging with actionable advice for missing `jul-to-slf4j` JAR.
- Updated tests in `MethodSetterTest` to enhance coverage for scalar coercion.
- Refactored `MethodSetter` to improve scalar type coercion logic and exception clarity.
- Simplified OpenTelemetry example in README; replaced XML example with YAML, added base instructions, and updated trace output.
predic8 added a commit that referenced this pull request Jan 5, 2026
* extend: Add OpenTelemetry example in YAML (#2528)

- Added `apis.yaml` with OpenTelemetry plugin configuration for distributed tracing in Membrane.
- Improved `OpenTelemetryInterceptor` logging with actionable advice for missing `jul-to-slf4j` JAR.
- Updated tests in `MethodSetterTest` to enhance coverage for scalar coercion.
- Refactored `MethodSetter` to improve scalar type coercion logic and exception clarity.
- Simplified OpenTelemetry example in README; replaced XML example with YAML, added base instructions, and updated trace output.

* refactor: rename test method in `MethodSetterTest` and fix typos in OpenTelemetry example documentation
@christiangoerdes christiangoerdes merged commit 3dc2891 into master Jan 6, 2026
3 of 4 checks passed
@christiangoerdes christiangoerdes deleted the mongodb-exchange-store-yaml-example branch January 6, 2026 07:58
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.

3 participants