Conversation
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds package Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
|
7e6de90 to
ea62825
Compare
2d9950f to
1554b53
Compare
869bf55 to
e65dccc
Compare
1554b53 to
e807cae
Compare
e65dccc to
633d32f
Compare
e807cae to
cb703ef
Compare
633d32f to
66cc058
Compare
66cc058 to
f37eed7
Compare
649c739 to
6896ceb
Compare
f37eed7 to
4416453
Compare
Confidence Score: 5/5Safe to merge — all extracted functions are pure string utilities, the governance plugin compiles and behaves identically to before, and the only finding is a documentation mismatch in the PR description. All remaining findings are P2: the implementation is functionally correct, the two extracted functions are pure string utilities with no side effects, and createCELEnvironment still resides and works correctly in the governance plugin. No files require special attention; the discrepancy is in the PR description, not the code. Important Files Changed
Reviews (10): Last reviewed commit: "refactor: Extracts routing utilites to a..." | Re-trigger Greptile |
|
@CodeRabbit-ai full review |
|
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@framework/routing/routing.go`:
- Around line 30-34: The regex replacements on expr using headerKeyPattern,
paramKeyPattern, headerInPattern and paramInPattern can mutate quoted CEL string
literals; change the normalization to be token-aware by first scanning expr and
skipping any text inside quoted string tokens (single and double quotes, with
escape handling) before applying ReplaceAllStringFunc, or alternatively parse
into CEL AST/tokens and apply the key-lowering only to identifier/map-key lookup
nodes; ensure headerKeyPattern, paramKeyPattern, headerInPattern and
paramInPattern are only applied to regions outside quoted strings so expressions
like model == "headers['X-Tier']" are left unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ff6ebcbb-8e0f-4675-9cf7-d83bb1c198a2
📒 Files selected for processing (4)
framework/routing/routing.goplugins/governance/routing.goplugins/governance/routing_test.goplugins/governance/store.go
💤 Files with no reviewable changes (1)
- plugins/governance/routing.go
fbf80a2 to
c8e97d7
Compare
246c43c to
2b88043
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
framework/routing/routing.go (1)
10-20:⚠️ Potential issue | 🟡 MinorAdd identifier boundaries to map-name regexes.
These patterns still match
headers/paramsas substrings of longer identifiers (e.g.,xheaders["K"],"k" in headersMap), which can rewrite unrelated symbols.Suggested patch
-var headerKeyPattern = regexp.MustCompile(`headers\[["']([^"']+)["']\]`) +var headerKeyPattern = regexp.MustCompile(`\bheaders\[["']([^"']+)["']\]`) -var headerInPattern = regexp.MustCompile(`["']([^"']+)["']\s+in\s+headers`) +var headerInPattern = regexp.MustCompile(`["']([^"']+)["']\s+in\s+\bheaders\b`) -var paramKeyPattern = regexp.MustCompile(`params\[["']([^"']+)["']\]`) +var paramKeyPattern = regexp.MustCompile(`\bparams\[["']([^"']+)["']\]`) -var paramInPattern = regexp.MustCompile(`["']([^"']+)["']\s+in\s+params`) +var paramInPattern = regexp.MustCompile(`["']([^"']+)["']\s+in\s+\bparams\b`)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@framework/routing/routing.go` around lines 10 - 20, The existing regexes headerKeyPattern, headerInPattern, paramKeyPattern and paramInPattern incorrectly match when "headers" or "params" appear as substrings of longer identifiers; update each pattern to require identifier boundaries around the map name (e.g., use word-boundary or negative lookbehind/lookahead for identifier chars so only standalone headers or params match) while preserving the captured key group and the rest of the pattern; apply this change to all four vars so rewrites only target true map access/membership like headers["X"] or "X" in params.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@framework/routing/routing.go`:
- Around line 10-20: The existing regexes headerKeyPattern, headerInPattern,
paramKeyPattern and paramInPattern incorrectly match when "headers" or "params"
appear as substrings of longer identifiers; update each pattern to require
identifier boundaries around the map name (e.g., use word-boundary or negative
lookbehind/lookahead for identifier chars so only standalone headers or params
match) while preserving the captured key group and the rest of the pattern;
apply this change to all four vars so rewrites only target true map
access/membership like headers["X"] or "X" in params.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6507a8b3-3bed-49fb-945e-e6aa4001d90b
📒 Files selected for processing (4)
framework/routing/routing.goplugins/governance/routing.goplugins/governance/routing_test.goplugins/governance/store.go
💤 Files with no reviewable changes (1)
- plugins/governance/routing.go
✅ Files skipped from review due to trivial changes (2)
- plugins/governance/routing_test.go
- plugins/governance/store.go
1a73c1b to
9f01c3f
Compare
2acff08 to
3562875
Compare
3562875 to
d54ccca
Compare
2c77290 to
684cf74
Compare
d54ccca to
dc92eb1
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
framework/routing/routing.go (1)
10-20:⚠️ Potential issue | 🟡 MinorAdd identifier boundaries to
headers/paramsregex targets.These patterns can still match substrings inside larger identifiers and rewrite unintended text. Constrain
headersandparamsto identifier boundaries.Suggested patch
-var headerKeyPattern = regexp.MustCompile(`headers\[["']([^"']+)["']\]`) +var headerKeyPattern = regexp.MustCompile(`\bheaders\[["']([^"']+)["']\]`) -var headerInPattern = regexp.MustCompile(`["']([^"']+)["']\s+in\s+headers`) +var headerInPattern = regexp.MustCompile(`["']([^"']+)["']\s+in\s+\bheaders\b`) -var paramKeyPattern = regexp.MustCompile(`params\[["']([^"']+)["']\]`) +var paramKeyPattern = regexp.MustCompile(`\bparams\[["']([^"']+)["']\]`) -var paramInPattern = regexp.MustCompile(`["']([^"']+)["']\s+in\s+params`) +var paramInPattern = regexp.MustCompile(`["']([^"']+)["']\s+in\s+\bparams\b`)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@framework/routing/routing.go` around lines 10 - 20, The regexes headerKeyPattern, headerInPattern, paramKeyPattern, and paramInPattern are currently matching "headers" and "params" inside larger identifiers; update each pattern to require identifier boundaries around the target words (e.g., use word-boundaries like \b around headers and params or equivalent negative-lookbehind/lookahead) so that matches only occur on the standalone identifiers (for example change occurrences of `headers\[` to `\bheaders\[` and `in\s+headers` to `\bin\s+headers\b`, and similarly for `params`) while preserving the existing capture groups for the key names.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@framework/routing/routing.go`:
- Around line 10-20: The regexes headerKeyPattern, headerInPattern,
paramKeyPattern, and paramInPattern are currently matching "headers" and
"params" inside larger identifiers; update each pattern to require identifier
boundaries around the target words (e.g., use word-boundaries like \b around
headers and params or equivalent negative-lookbehind/lookahead) so that matches
only occur on the standalone identifiers (for example change occurrences of
`headers\[` to `\bheaders\[` and `in\s+headers` to `\bin\s+headers\b`, and
similarly for `params`) while preserving the existing capture groups for the key
names.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f44bba35-6e89-4aea-bc6e-707f3b104157
📒 Files selected for processing (4)
framework/routing/routing.goplugins/governance/routing.goplugins/governance/routing_test.goplugins/governance/store.go
💤 Files with no reviewable changes (1)
- plugins/governance/routing.go
✅ Files skipped from review due to trivial changes (1)
- plugins/governance/store.go
🚧 Files skipped from review as they are similar to previous changes (1)
- plugins/governance/routing_test.go
dc92eb1 to
6328594
Compare
684cf74 to
5465c4e
Compare
6328594 to
a9ceab4
Compare
5465c4e to
3df2fd7
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
plugins/governance/store.go (1)
3449-3459:⚠️ Potential issue | 🟡 MinorTrim before empty-defaulting to keep validation and compile paths consistent.
routing.ValidateCELExpressiontrims internally, but Line [3450]-Line [3452] only treats exact""as empty. Trimming once up front keeps whitespace-only expressions aligned with the same default"true"path.Suggested patch
- expr := rule.CelExpression + expr := strings.TrimSpace(rule.CelExpression) if expr == "" { expr = "true" }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/governance/store.go` around lines 3449 - 3459, Trim rule.CelExpression into expr before checking for empty and before further normalization/validation so whitespace-only expressions get the same default "true" path; i.e., call strings.TrimSpace (or equivalent) on expr prior to the empty check, then pass the trimmed expr into routing.NormalizeMapKeysInCEL and routing.ValidateCELExpression to keep compile/validation behavior consistent for rule.CelExpression.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@plugins/governance/store.go`:
- Around line 3449-3459: Trim rule.CelExpression into expr before checking for
empty and before further normalization/validation so whitespace-only expressions
get the same default "true" path; i.e., call strings.TrimSpace (or equivalent)
on expr prior to the empty check, then pass the trimmed expr into
routing.NormalizeMapKeysInCEL and routing.ValidateCELExpression to keep
compile/validation behavior consistent for rule.CelExpression.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 814b03e3-d7af-4b70-9b4a-7845b4b3c3a5
📒 Files selected for processing (4)
framework/routing/routing.goplugins/governance/routing.goplugins/governance/routing_test.goplugins/governance/store.go
💤 Files with no reviewable changes (1)
- plugins/governance/routing.go
🚧 Files skipped from review as they are similar to previous changes (1)
- plugins/governance/routing_test.go
Merge activity
|
The base branch was changed.

Summary
Extracted routing-related CEL (Common Expression Language) functionality into a dedicated framework package to improve code organization and reusability. This refactoring moves CEL environment creation, expression validation, and map key normalization functions from the governance plugin to a shared routing framework.
Changes
framework/routing/routing.gopackage with exported functions for CEL operationscreateCELEnvironment,validateCELExpression, andnormalizeMapKeysInCELfunctions from governance plugin to routing frameworkType of change
Affected areas
How to test
Validate that the refactoring maintains existing functionality by running the test suite:
Screenshots/Recordings
N/A - This is a code refactoring with no UI changes.
Breaking changes
This is an internal refactoring that maintains the same public API and functionality.
Related issues
N/A
Security considerations
No security implications - this is a code organization refactoring that maintains the same CEL expression validation and normalization logic.
Checklist
docs/contributing/README.mdand followed the guidelines