Skip to content

Conversation

@google-labs-jules
Copy link

This PR implements the logic to distinguish between policies attached at the API level versus the Resource/Route level.

Key changes:

  1. SDK: Added AttachedTo field to PolicyMetadata in sdk/gateway/policy/v1alpha/interface.go.
  2. Gateway Controller: Modified handlers.go and main.go to pass "api" or "route" as context when converting policies, injecting this value into the policy parameters.
  3. Policy Engine: Updated handler.go to extract the attachedTo parameter and populate the PolicyMetadata.
  4. Basic Rate Limit Policy: Updated basic_ratelimit.go to check metadata.AttachedTo. If it is "api", the rate limit key extractor is set to apiname, otherwise it defaults to routename.

This ensures that API-level rate limits are applied correctly using the API name as the key, while Route-level rate limits continue to use the Route name.


PR created automatically by Jules for task 11151761427082548090 started by @Tharsanan1

- Updated SDK PolicyMetadata to include AttachedTo field
- Updated Gateway Controller to inject AttachedTo parameter ("api" or "route") during policy conversion
- Updated Policy Engine to extract AttachedTo from parameters and set it in PolicyMetadata
- Updated Basic Rate Limit policy to use "apiname" key extractor when AttachedTo is "api"
@google-labs-jules
Copy link
Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

google-labs-jules bot and others added 4 commits January 14, 2026 05:06
- Updated SDK PolicyMetadata to include AttachedTo field
- Updated Gateway Controller to inject AttachedTo parameter ("api" or "route") during policy conversion
- Updated Policy Engine to extract AttachedTo from parameters and set it in PolicyMetadata
- Updated Basic Rate Limit policy to use "apiname" key extractor when AttachedTo is "api"
- Updated integration tests to verify new behavior and fix regressions caused by scoping changes
- Merged latest changes from ratelimit-latest.
- Updated `gateway/it/features/basic-ratelimit.feature` to align with the new rate limiting behavior:
  - API-level attachment now implies a shared bucket (per API).
  - Route-level attachment (per operation) implies independent buckets.
  - Adjusted test expectations and configurations accordingly.
- Verified that all integration tests pass.
- Merged latest changes from ratelimit-latest.
- Updated `gateway/it/features/basic-ratelimit.feature` to align with the new rate limiting behavior:
  - API-level attachment now implies a shared bucket (per API).
  - Route-level attachment (per operation) implies independent buckets.
  - Adjusted test expectations and configurations accordingly.
- Verified that all integration tests pass.
@Tharsanan1 Tharsanan1 marked this pull request as ready for review January 15, 2026 09:33
@Tharsanan1 Tharsanan1 merged commit c99aa06 into ratelimit-latest Jan 15, 2026
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