Updated policy definitions#1817
Conversation
📝 WalkthroughUpdated policy definitions for released policiesThis PR updates the policy definitions for four released policies in the gateway controller to version 1.0.3: Version updates across all policies:
New functional parameter:
The changes maintain backward compatibility with existing configurations while providing enhanced flexibility for consumer-specific rate limiting behavior. WalkthroughFour gateway controller policy definition files have been updated with version increments from v1.0.2 to v1.0.3. The advanced-ratelimit and api-key-auth policies receive only version updates with no functional changes. The llm-cost-based-ratelimit and token-based-ratelimit policies introduce a new boolean parameter 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
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 `@gateway/gateway-controller/default-policies/llm-cost-based-ratelimit.yaml`:
- Around line 45-53: The top-level behavior text is outdated given consumerBased
defaults to false; update the main description (the file-level description
field) to state that by default a single shared rate limit applies across all
consumers and that setting consumerBased (boolean, default: false) to true
enables per-consumer scoping using the x-wso2-application-id metadata; ensure
the new wording clearly contrasts the default shared behavior with the optional
per-consumer enforcement and references the consumerBased flag and
x-wso2-application-id so readers know how to enable per-consumer limits.
🪄 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: 40343e3f-0291-43c9-9813-e376a6bbb3a3
📒 Files selected for processing (4)
gateway/gateway-controller/default-policies/advanced-ratelimit.yamlgateway/gateway-controller/default-policies/api-key-auth.yamlgateway/gateway-controller/default-policies/llm-cost-based-ratelimit.yamlgateway/gateway-controller/default-policies/token-based-ratelimit.yaml
| consumerBased: | ||
| type: boolean | ||
| x-wso2-policy-advanced-param: false | ||
| description: | | ||
| When true, rate limits are applied per consumer (GenAI application) identified | ||
| by the x-wso2-application-id metadata key set by the api-key-auth policy. | ||
| Each application gets its own independent cost counter. | ||
| When false (default), a single shared limit applies across all consumers. | ||
| default: false |
There was a problem hiding this comment.
Top-level behavior description should be aligned with the new default.
With consumerBased defaulting to false, the file-level description still implying always per-consumer enforcement is now misleading. Please update the description to reflect shared-by-default behavior with optional per-consumer scoping.
Suggested wording update
- The policy reads costs from SharedContext.Metadata under "x-llm-cost" (set by the llm-cost
- system policy) and enforces per-consumer spending limits (e.g., $10 per hour, $100 per day).
+ The policy reads costs from SharedContext.Metadata under "x-llm-cost" (set by the llm-cost
+ system policy) and enforces spending limits (e.g., $10 per hour, $100 per day).
+ When `consumerBased` is enabled, limits are scoped per consumer/application.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@gateway/gateway-controller/default-policies/llm-cost-based-ratelimit.yaml`
around lines 45 - 53, The top-level behavior text is outdated given
consumerBased defaults to false; update the main description (the file-level
description field) to state that by default a single shared rate limit applies
across all consumers and that setting consumerBased (boolean, default: false) to
true enables per-consumer scoping using the x-wso2-application-id metadata;
ensure the new wording clearly contrasts the default shared behavior with the
optional per-consumer enforcement and references the consumerBased flag and
x-wso2-application-id so readers know how to enable per-consumer limits.
Purpose