Skip to content

Improve yaml syntax: Use collapsed for suitable classes (Breaking Change)#2776

Merged
christiangoerdes merged 3 commits into
masterfrom
yaml-syntax-improvement
Feb 12, 2026
Merged

Improve yaml syntax: Use collapsed for suitable classes (Breaking Change)#2776
christiangoerdes merged 3 commits into
masterfrom
yaml-syntax-improvement

Conversation

@christiangoerdes

@christiangoerdes christiangoerdes commented Feb 12, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Configuration

    • Renamed htpasswd provider element and its path property to a clearer file-based provider with a location field.
  • Style

    • Default collapse behavior improved for several configuration elements in the UI/config view.
  • Documentation

    • Updated README and many example configs to use the renamed provider and simplified inline/value syntax for flow and disallow entries.
  • Chores

    • Added license header to a test file.

@coderabbitai

coderabbitai Bot commented Feb 12, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Added collapsed = true to several @MCElement annotations, renamed fileUserDataProviderhtpasswdFileProvider and htpasswdPathlocation (with corresponding getter/setter), and updated examples, docs, and tests to match these metadata and config changes.

Changes

Cohort / File(s) Summary
MCElement collapsed additions
core/src/main/java/com/predic8/membrane/core/graphql/blocklist/filters/MutationFilter.java, core/src/main/java/com/predic8/membrane/core/interceptor/CountInterceptor.java, core/src/main/java/com/predic8/membrane/core/interceptor/apikey/stores/KeyTable.java, core/src/main/java/com/predic8/membrane/core/interceptor/apikey/stores/ScopeTable.java, core/src/main/java/com/predic8/membrane/core/interceptor/oauth2client/rf/PublicUrlManager.java, core/src/main/java/com/predic8/membrane/core/openapi/serviceproxy/APIProxy.java
Added collapsed = true to @MCElement annotations; only annotation metadata changed, no runtime logic edits.
Authentication provider refactor
core/src/main/java/com/predic8/membrane/core/interceptor/authentication/session/FileUserDataProvider.java
Renamed MCElement from fileUserDataProviderhtpasswdFileProvider; renamed public methods getHtpasswdPath()/setHtpasswdPath()getLocation()/setLocation() and updated the internal field and file-read usage.
Example/config updates (YAML/XML/README)
README.md, distribution/examples/loadbalancing/*/apis.yaml, distribution/examples/security/basic-auth/simple/README.md, distribution/examples/security/basic-auth/simple/apis.yaml, distribution/examples/security/basic-auth/simple/proxies.xml, distribution/tutorials/security/95-GraphQL-Protection.yaml, distribution/examples/security/api-key/jdbc-api-key-store/apis.yaml
Flattened several YAML mappings to inline scalar forms (e.g., - counter: Name), replaced fileUserDataProvider/htpasswdPath with htpasswdFileProvider/location in examples and docs.
Tests & headers
core/src/test/java/com/predic8/membrane/core/interceptor/templating/GroovyTemplateEscapingTest.java, distribution/src/test/java/com/predic8/membrane/examples/ConfigSerializationTest.java
Inserted Apache-2.0 license header in a test file and updated a comment in ConfigSerializationTest to reflect htpasswdFileProvider naming.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • rrayst
  • predic8

Poem

🐰 I hopped through XML and YAML bright,

Collapsed the tags to tidy sight,
A provider renamed, a path now “location”,
Examples simplified across the station,
A cheerful nibble, config set to right. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.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 title clearly and specifically describes the main change: introducing collapsed parameter to MCElement annotations for suitable classes as a breaking change.

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

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch yaml-syntax-improvement

No actionable comments were generated in the recent review. 🎉


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
core/src/main/java/com/predic8/membrane/core/interceptor/authentication/session/FileUserDataProvider.java (2)

30-43: ⚠️ Potential issue | 🟡 Minor

Javadoc still references the old element name fileUserDataProvider.

Line 33 in the @description block still mentions fileUserDataProvider, but the element was renamed to htpasswdFileProvider on line 43. Update the documentation to match the new name.

Proposed fix
-  *   The <i>fileUserDataProvider</i> loads users from a file in the format
+  *   The <i>htpasswdFileProvider</i> loads users from a file in the format

108-115: ⚠️ Potential issue | 🟠 Major

Potential NullPointerException if location is not set before init() is called.

Paths.get(this.location) will throw NullPointerException if location is null. Consider adding a null/empty check with a descriptive error message, or annotating setLocation with @Required.

Proposed fix
     public void init(Router router) {
+        if (location == null || location.isBlank()) {
+            throw new IllegalStateException("'location' must be set on htpasswdFileProvider");
+        }
         List<String> lines;
         try {
             lines = Files.readAllLines(Paths.get(this.location));
🤖 Fix all issues with AI agents
In
`@core/src/main/java/com/predic8/membrane/core/interceptor/authentication/session/FileUserDataProvider.java`:
- Around line 43-57: The MCElement name was changed from "fileUserDataProvider"
to "htpasswdFileProvider" and the attribute from "htpasswdPath" to "location"
but docs, samples, tests and Javadoc were not updated; update
docs/MIGRATION-GUIDE.md to list this breaking change and the exact rename,
replace the old element/attribute names in the sample configs
(distribution/examples/security/basic-auth/simple/proxies.xml, apis.yaml,
README.md and root README.md), update YAMLComponentsParsingTest
(annot/src/test/java/com/predic8/membrane/annot/YAMLComponentsParsingTest.java)
to expect "htpasswdFileProvider" and "location", and update the Javadoc in
FileUserDataProvider (class FileUserDataProvider, setLocation/getLocation) to
reference the new names so all examples, tests and docs consistently use
htpasswdFileProvider/location.

@membrane-ci-server

Copy link
Copy Markdown

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

@christiangoerdes christiangoerdes linked an issue Feb 12, 2026 that may be closed by this pull request
@christiangoerdes

Copy link
Copy Markdown
Collaborator Author

/ok-to-test

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In
`@core/src/main/java/com/predic8/membrane/core/interceptor/CountInterceptor.java`:
- Line 33: Update the Javadoc YAML example in CountInterceptor to use
collapsed-mode syntax by removing the redundant attribute name; change the
example that currently shows `counter: name: Mock Node 1` to the collapsed form
`counter: Mock Node 1` so the YAML sets the counter's name instead of parsing
the whole string; follow the pattern used in YAMLParsingCollapsedTest.java and
ensure the example is updated near the CountInterceptor class documentation.

In `@distribution/examples/security/basic-auth/simple/README.md`:
- Line 54: Update the README sentence that references htpasswdFileProvider to
use a hyphenated compound modifier: change "htpasswd formatted file" to
"htpasswd-formatted file" so the sentence reads e.g. "the htpasswdFileProvider
can be used to read basic authentication data from an htpasswd-formatted file";
keep the rest of the sentence unchanged.
🧹 Nitpick comments (1)
core/src/main/java/com/predic8/membrane/core/interceptor/authentication/session/FileUserDataProvider.java (1)

52-55: Add @Required to setLocation to fail fast with a clear error.

Without @Required, if a user omits the location attribute, init() will throw a NullPointerException at Paths.get(this.location) (line 112) with no indication of which configuration attribute is missing. This pattern is consistently used throughout the session provider classes (LDAPUserDataProvider, JdbcUserDataProvider, EmailTokenProvider, etc.) for required configuration attributes.

Proposed fix
+    `@Required`
     `@MCAttribute`
     public void setLocation(String path) {
         this.location = path;
     }

Add the import:

import com.predic8.membrane.annot.Required;

Comment thread distribution/examples/security/basic-auth/simple/README.md
@christiangoerdes christiangoerdes marked this pull request as ready for review February 12, 2026 08:44
@christiangoerdes christiangoerdes merged commit fb689a3 into master Feb 12, 2026
5 checks passed
@christiangoerdes christiangoerdes deleted the yaml-syntax-improvement branch February 12, 2026 09:19
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.

Use @MCElement(collapsed=true) for suitable classes

2 participants