Skip to content

Conversation

@christiangoerdes
Copy link
Collaborator

@christiangoerdes christiangoerdes commented Feb 11, 2026

Summary by CodeRabbit

  • Documentation
    • Standardized API key examples to YAML and renamed extractor keys from legacy names to simpler header/query across docs and examples.
  • Bug Fixes
    • Ignore blank header names when configuring header extractors to avoid unintended empty-header behavior.
  • Chores
    • Cleaned and compacted API key configuration examples for clearer presentation.

@christiangoerdes
Copy link
Collaborator Author

/ok-to-test

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Renamed API-key extractor identifiers in docs/config from headerExtractor/queryParamExtractor to header/query; replaced XML examples in Javadoc and samples with YAML snippets; updated @MCElement annotations on extractor classes. Minor runtime tweak: ApiKeyHeaderExtractor#setHeaderName ignores blank inputs. No public API signatures changed.

Changes

Cohort / File(s) Summary
Interceptor docs & internal samples
core/src/main/java/com/predic8/membrane/core/interceptor/apikey/ApiKeysInterceptor.java, core/src/main/java/com/predic8/membrane/core/util/jdbc/AbstractJdbcSupport.java
Rewrote Javadoc/sample configuration examples from XML to YAML and replaced sample <headerExtractor /> with <header /> in internal strings (documentation-only).
Extractor classes
core/src/main/java/com/predic8/membrane/core/interceptor/apikey/extractors/ApiKeyHeaderExtractor.java, core/src/main/java/com/predic8/membrane/core/interceptor/apikey/extractors/ApiKeyQueryParamExtractor.java
Changed @MCElement annotations to new element names/ids (name="header", id="headerExtractor" and name="query", id="queryParamExtractor"). Javadocs now show YAML examples. ApiKeyHeaderExtractor#setHeaderName now ignores blank inputs.
Examples & READMEs (YAML / XML snippets)
distribution/examples/security/api-key/.../*, distribution/examples/openapi/.../*, distribution/examples/security/jwt/.../*, README.md
Renamed extractor keys in example configs and README snippets from headerExtractorheader and queryParamExtractorquery; adjusted some mappings/scalars and name fields to match new keys (documentation/config examples only).
Tests
core/src/test/java/.../APIProxySpringConfigurationTest.java
Updated XML test snippets to use <header> instead of <headerExtractor> inside API-key configuration examples to match new element name.

Sequence Diagram(s)

(omitted — changes are documentation/annotation-oriented with a minor local setter behavior change; no new multi-component control flow to visualize)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • APIKey: add apidoc #2144: Modifies API key extractor classes and related docs (overlaps with extractor annotation/name changes).
  • API Key YAML Example #2535: Touches ApiKeysInterceptor and ApiKeyHeaderExtractor (related config/docs and extractor handling).
  • Migrate examples to yaml #2539: Renames/migrates API-key extractor/config elements (headerExtractor→header, queryParamExtractor→query) across examples and annotations.

Suggested labels

7.x

Suggested reviewers

  • predic8
  • rrayst

Poem

🐰 I hopped from XML to YAML bright,
I nudged a header into morning light.
Blank names I skip with gentle care,
Docs now whisper YAML everywhere.
A tiny hop — config set right. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% 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 accurately summarizes the main change: updating headerExtractor YAML syntax as a breaking change, which is reflected across all modified files consistently.

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

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

No actionable comments were generated in the recent review. 🎉

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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: 2

🤖 Fix all issues with AI agents
In
`@core/src/main/java/com/predic8/membrane/core/interceptor/apikey/ApiKeysInterceptor.java`:
- Around line 38-46: Update the YAML example in ApiKeysInterceptor (the block
showing "api: port:2000 ...") to insert a space after the colon in the port
mapping so it reads "port: 2000"; ensure the change is made inside the YAML code
block in the ApiKeysInterceptor.java Javadoc/example so users can copy valid
YAML.

In
`@core/src/main/java/com/predic8/membrane/core/interceptor/apikey/extractors/ApiKeyHeaderExtractor.java`:
- Line 38: The MCElement annotation on ApiKeyHeaderExtractor
(`@MCElement`(name="headerExtractor", component = false, collapsed = true))
requires collapsed YAML syntax; update the example YAML entries that use
expanded form (e.g., headerExtractor: {name: X-Key} or headerExtractor: {name:
"X-Api-Key"}) to the collapsed forms: use headerExtractor: X-Key for a custom
header or headerExtractor: {} for the default header; locate occurrences in the
API key example apis.yaml files (the RBAC and apikey-openapi examples) and
replace the expanded mappings accordingly so they parse with the collapsed=true
constraint.

@membrane-ci-server
Copy link

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

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

🤖 Fix all issues with AI agents
In `@distribution/examples/security/api-key/simple/apis.yaml`:
- Line 17: The YAML contains a null for the collapsed element `headerExtractor`
which the collapsed-element parser forbids and causes
ParsingException("Collapsed element must not be null."); update the
`headerExtractor` entry (the one contrasted with `queryParamExtractor`) to be a
non-null scalar or an empty object — e.g., replace the null with a header name
like `X-Api-Key` or use the explicit empty object form `{}` so the parser
accepts the value for the `headerExtractor` element.

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

🤖 Fix all issues with AI agents
In
`@core/src/main/java/com/predic8/membrane/core/interceptor/apikey/ApiKeysInterceptor.java`:
- Around line 38-46: The YAML example in ApiKeysInterceptor uses a scalar
extractor form ("- header: X-Api-Key") that is inconsistent with
ApiKeyHeaderExtractor's documented object forms; update the example in
ApiKeysInterceptor to use the object syntax shown in ApiKeyHeaderExtractor (e.g.
replace "- header: X-Api-Key" with "- header: { name: X-Api-Key }") so the
example matches the extractor's docs and the parser expectations, or
alternatively add collapsed = true to the `@MCElement` on ApiKeyHeaderExtractor if
you prefer to support the scalar form—refer to the ApiKeysInterceptor YAML
example and the ApiKeyHeaderExtractor `@MCElement` declaration to implement the
chosen change.
🧹 Nitpick comments (1)
core/src/main/java/com/predic8/membrane/core/interceptor/apikey/extractors/ApiKeyHeaderExtractor.java (1)

62-62: Silent fallback on blank input may mask misconfiguration.

If a user accidentally sets name: "" or name: " ", the setter silently retains the default X-Api-Key with no warning. Consider logging a warning or throwing an IllegalArgumentException so misconfigurations surface early rather than silently falling back to the default.

Suggested improvement
     `@MCAttribute`(attributeName = "name")
     public void setHeaderName(String headerName) {
-        if(!headerName.isBlank()) this.headerName = new HeaderName(headerName);
+        if (headerName.isBlank()) {
+            log.warn("Blank header name provided; using default '{}'", this.headerName.getName());
+            return;
+        }
+        this.headerName = new HeaderName(headerName);
     }

This would require adding a logger field (similar to ApiKeyQueryParamExtractor):

private static final Logger log = LoggerFactory.getLogger(ApiKeyHeaderExtractor.class);

@predic8 predic8 merged commit db17821 into master Feb 12, 2026
5 checks passed
@predic8 predic8 deleted the improve-api-key-yaml-syntax branch February 12, 2026 08:07
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