feat: add case-insensitive helper methods for HTTP request headers and query parameters#1297
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
📝 WalkthroughSummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughAdded case-insensitive header and query lookup helpers to HTTPRequest, updated documentation to recommend those helpers, and refactored the governance plugin to use the new helpers instead of an internal lookup function. Changes
Sequence Diagram(s)(omitted) Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~22 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 unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @core/schemas/plugin.go:
- Line 46: The comment above the function incorrectly names it as
caseInsensitiveHeaderLookup; update the comment to reference the actual function
name caseInsensitiveLookup so the docstring matches the function identifier and
avoids confusion when locating caseInsensitiveLookup in the codebase.
🧹 Nitpick comments (1)
docs/plugins/writing-go-plugin.mdx (1)
244-246: Consider recommending lowercase keys when setting headers.The example shows setting headers with mixed case (
X-Custom-Header), but theHTTPRequeststruct comments indicate that "keys are lowercase". For consistency and to ensure subsequent lookups work correctly, consider recommending lowercase keys when setting:📝 Suggested clarification
-// For setting headers, use direct map access -req.Headers["X-Custom-Header"] = "value" +// For setting headers, use lowercase keys for consistency +req.Headers["x-custom-header"] = "value"
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
core/changelog.mdcore/schemas/plugin.godocs/plugins/writing-go-plugin.mdxdocs/plugins/writing-wasm-plugin.mdxplugins/governance/main.go
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
always check the stack if there is one for the current PR. do not give localized reviews for the PR, always see all changes in the light of the whole stack of PRs (if there is a stack, if there is no stack you can continue to make localized suggestions/reviews)
Files:
docs/plugins/writing-go-plugin.mdxplugins/governance/main.gocore/changelog.mdcore/schemas/plugin.godocs/plugins/writing-wasm-plugin.mdx
🧠 Learnings (4)
📚 Learning: 2025-12-30T05:37:48.365Z
Learnt from: Pratham-Mishra04
Repo: maximhq/bifrost PR: 1180
File: docs/features/mcp/connecting-to-servers.mdx:452-458
Timestamp: 2025-12-30T05:37:48.365Z
Learning: When reviewing documentation PRs in a Graphite-managed stack, first check related or previous PRs in the stack for feature implementations before flagging documentation as incorrect or unsupported. Documentation MDX files often reference features implemented in earlier stack PRs; verify that the documented behavior exists in earlier changes and that the docs accurately reflect the implemented state before requesting edits.
Applied to files:
docs/plugins/writing-go-plugin.mdxdocs/plugins/writing-wasm-plugin.mdx
📚 Learning: 2025-12-09T17:07:42.007Z
Learnt from: qwerty-dvorak
Repo: maximhq/bifrost PR: 1006
File: core/schemas/account.go:9-18
Timestamp: 2025-12-09T17:07:42.007Z
Learning: In core/schemas/account.go, the HuggingFaceKeyConfig field within the Key struct is currently unused and reserved for future Hugging Face inference endpoint deployments. Do not flag this field as missing from OpenAPI documentation or require its presence in the API spec until the feature is actively implemented and used. When the feature is added, update the OpenAPI docs accordingly; otherwise, treat this field as non-breaking and not part of the current API surface.
Applied to files:
plugins/governance/main.gocore/schemas/plugin.go
📚 Learning: 2025-12-29T11:54:55.836Z
Learnt from: akshaydeo
Repo: maximhq/bifrost PR: 1153
File: framework/configstore/rdb.go:2221-2246
Timestamp: 2025-12-29T11:54:55.836Z
Learning: In Go reviews, do not flag range-over-int patterns like for i := range n as compile-time errors, assuming Go 1.22+ semantics. Only flag actual range-capable values (slices, arrays, maps, channels, strings) and other compile-time issues. This applies to all Go files across the repository.
Applied to files:
plugins/governance/main.gocore/schemas/plugin.go
📚 Learning: 2025-12-22T10:50:40.990Z
Learnt from: Pratham-Mishra04
Repo: maximhq/bifrost PR: 1154
File: plugins/governance/store.go:1165-1186
Timestamp: 2025-12-22T10:50:40.990Z
Learning: In the Bifrost governance plugin, budgets and rate limits have 1:1 relationships with their parent entities (virtual keys, teams, customers). Do not assume sharing; ensure cascade deletion logic only deletes budgets/rate limits when there are no shared references. Enforce invariants in code and add tests to verify no cross-entity sharing and that cascade deletes only remove the specific child of the parent. If a counterexample arises, adjust data model or add guards.
Applied to files:
plugins/governance/main.go
🧬 Code graph analysis (1)
plugins/governance/main.go (2)
core/schemas/utils.go (1)
Ptr(14-16)core/utils.go (1)
Ptr(56-58)
🔇 Additional comments (6)
core/changelog.md (1)
1-1: LGTM!The changelog entry clearly describes the feature addition.
plugins/governance/main.go (1)
232-260: LGTM!The refactoring to use
CaseInsensitiveHeaderLookup()from the core schemas is clean and consistent. The logic flow for extracting virtual keys from various headers remains unchanged while benefiting from the centralized case-insensitive lookup implementation.docs/plugins/writing-wasm-plugin.mdx (1)
754-758: LGTM!The documentation correctly explains the case-insensitive handling requirements for WASM plugins and appropriately references the Go native helper methods as a pattern to follow.
core/schemas/plugin.go (1)
39-67: LGTM!The implementation is well-structured with appropriate defensive checks. The lookup order (exact match → lowercase → case-insensitive iteration) is optimal for performance, prioritizing common cases first.
docs/plugins/writing-go-plugin.mdx (2)
94-104: LGTM!The example code clearly demonstrates the recommended pattern for reading headers using the case-insensitive helper method.
232-249: LGTM!The Note block provides clear guidance with good examples showing the flexibility of the helper methods across different casing conventions.
a96208e to
1b5ab71
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @docs/plugins/writing-wasm-plugin.mdx:
- Around line 754-758: The comments on the HTTPRequest struct incorrectly state
that header/query keys are lowercase; update the comment above the HTTPRequest
type (remove the phrase "keys are lowercase") to reflect that headers and query
parameters preserve the original casing sent by the client and recommend using
CaseInsensitiveHeaderLookup() and CaseInsensitiveQueryLookup() helpers for
lookup; keep the rest of the comment intact and ensure it matches behavior
verified by fasthttpToHTTPRequest and TestFasthttpToHTTPRequest.
🧹 Nitpick comments (1)
core/changelog.md (1)
1-1: Consider using "feat:" prefix for consistency.The PR title uses "feat:" but this changelog entry uses "chore:". Since this introduces new public API methods (
CaseInsensitiveHeaderLookupandCaseInsensitiveQueryLookup), "feat:" would be more appropriate to accurately categorize the change.Suggested fix
-- chore: added case-insensitive helper methods for header and query parameter lookups in HTTPRequest +- feat: added case-insensitive helper methods for header and query parameter lookups in HTTPRequest
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
core/changelog.mdcore/schemas/plugin.godocs/plugins/writing-go-plugin.mdxdocs/plugins/writing-wasm-plugin.mdxplugins/governance/main.go
🚧 Files skipped from review as they are similar to previous changes (2)
- plugins/governance/main.go
- docs/plugins/writing-go-plugin.mdx
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
always check the stack if there is one for the current PR. do not give localized reviews for the PR, always see all changes in the light of the whole stack of PRs (if there is a stack, if there is no stack you can continue to make localized suggestions/reviews)
Files:
docs/plugins/writing-wasm-plugin.mdxcore/schemas/plugin.gocore/changelog.md
🧠 Learnings (3)
📚 Learning: 2025-12-30T05:37:48.365Z
Learnt from: Pratham-Mishra04
Repo: maximhq/bifrost PR: 1180
File: docs/features/mcp/connecting-to-servers.mdx:452-458
Timestamp: 2025-12-30T05:37:48.365Z
Learning: When reviewing documentation PRs in a Graphite-managed stack, first check related or previous PRs in the stack for feature implementations before flagging documentation as incorrect or unsupported. Documentation MDX files often reference features implemented in earlier stack PRs; verify that the documented behavior exists in earlier changes and that the docs accurately reflect the implemented state before requesting edits.
Applied to files:
docs/plugins/writing-wasm-plugin.mdx
📚 Learning: 2025-12-09T17:07:42.007Z
Learnt from: qwerty-dvorak
Repo: maximhq/bifrost PR: 1006
File: core/schemas/account.go:9-18
Timestamp: 2025-12-09T17:07:42.007Z
Learning: In core/schemas/account.go, the HuggingFaceKeyConfig field within the Key struct is currently unused and reserved for future Hugging Face inference endpoint deployments. Do not flag this field as missing from OpenAPI documentation or require its presence in the API spec until the feature is actively implemented and used. When the feature is added, update the OpenAPI docs accordingly; otherwise, treat this field as non-breaking and not part of the current API surface.
Applied to files:
core/schemas/plugin.go
📚 Learning: 2025-12-29T11:54:55.836Z
Learnt from: akshaydeo
Repo: maximhq/bifrost PR: 1153
File: framework/configstore/rdb.go:2221-2246
Timestamp: 2025-12-29T11:54:55.836Z
Learning: In Go reviews, do not flag range-over-int patterns like for i := range n as compile-time errors, assuming Go 1.22+ semantics. Only flag actual range-capable values (slices, arrays, maps, channels, strings) and other compile-time issues. This applies to all Go files across the repository.
Applied to files:
core/schemas/plugin.go
🔇 Additional comments (2)
core/schemas/plugin.go (2)
39-47: LGTM!The public API methods are clean and provide a straightforward interface for case-insensitive lookups. The delegation to a shared helper promotes code reuse.
49-71: Well-designed lookup with progressive fallback strategy.The three-tier approach (exact → lowercase → case-insensitive iteration) is a good optimization that provides O(1) performance for the common cases while maintaining full case-insensitivity via the fallback iteration. The nil/empty guards are appropriate.
…ameter lookups in HTTPRequest
1b5ab71 to
fc800e9
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
core/schemas/plugin.go (1)
49-71: Well-structured three-tier lookup strategy.The implementation is efficient with good defensive checks:
- O(1) exact match first
- O(1) lowercase optimization for headers commonly stored in lowercase
- O(n) fallback for complete case-insensitivity
Consider expanding the comment on line 59 to clarify the optimization rationale:
📝 Optional: clarify comment
- // lower key checks + // Optimization: check lowercase key directly (common for HTTP headers stored normalized) lowerKey := strings.ToLower(key)
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
core/changelog.mdcore/schemas/plugin.godocs/plugins/writing-go-plugin.mdxdocs/plugins/writing-wasm-plugin.mdxplugins/governance/main.go
✅ Files skipped from review due to trivial changes (1)
- core/changelog.md
🚧 Files skipped from review as they are similar to previous changes (3)
- docs/plugins/writing-wasm-plugin.mdx
- docs/plugins/writing-go-plugin.mdx
- plugins/governance/main.go
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
always check the stack if there is one for the current PR. do not give localized reviews for the PR, always see all changes in the light of the whole stack of PRs (if there is a stack, if there is no stack you can continue to make localized suggestions/reviews)
Files:
core/schemas/plugin.go
🧠 Learnings (2)
📚 Learning: 2025-12-09T17:07:42.007Z
Learnt from: qwerty-dvorak
Repo: maximhq/bifrost PR: 1006
File: core/schemas/account.go:9-18
Timestamp: 2025-12-09T17:07:42.007Z
Learning: In core/schemas/account.go, the HuggingFaceKeyConfig field within the Key struct is currently unused and reserved for future Hugging Face inference endpoint deployments. Do not flag this field as missing from OpenAPI documentation or require its presence in the API spec until the feature is actively implemented and used. When the feature is added, update the OpenAPI docs accordingly; otherwise, treat this field as non-breaking and not part of the current API surface.
Applied to files:
core/schemas/plugin.go
📚 Learning: 2025-12-29T11:54:55.836Z
Learnt from: akshaydeo
Repo: maximhq/bifrost PR: 1153
File: framework/configstore/rdb.go:2221-2246
Timestamp: 2025-12-29T11:54:55.836Z
Learning: In Go reviews, do not flag range-over-int patterns like for i := range n as compile-time errors, assuming Go 1.22+ semantics. Only flag actual range-capable values (slices, arrays, maps, channels, strings) and other compile-time issues. This applies to all Go files across the repository.
Applied to files:
core/schemas/plugin.go
🔇 Additional comments (1)
core/schemas/plugin.go (1)
39-47: Clean delegation pattern for the public API.The methods are minimal and correctly delegate to the shared helper. The documentation clearly describes the case-insensitive behavior.

Summary
Added case-insensitive helper methods for header and query parameter lookups in HTTPRequest to improve plugin development experience and consistency.
Changes
CaseInsensitiveHeaderLookup()andCaseInsensitiveQueryLookup()helper methods to the HTTPRequest structcaseInsensitiveLookup()function that handles various lookup scenariosType of change
Affected areas
How to test
Test the new helper methods with various header and query parameter cases:
Breaking changes
Related issues
Improves developer experience when working with HTTP headers and query parameters in plugins.
Security considerations
No security implications. This change only affects how headers and query parameters are accessed.
Checklist