Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: ratelimit: validation error path or headers must be set when both path and headers fields are present in CR #1629

Open
Ressetkk opened this issue Jan 21, 2025 · 0 comments
Assignees
Labels
area/api-gateway Issues or PRs related to api-gateway kind/bug Categorizes issue or PR as related to a bug.
Milestone

Comments

@Ressetkk
Copy link
Contributor

Ressetkk commented Jan 21, 2025

When the following rate limit CR is applied the the validation returns an error:

The RateLimit "ratelimit-header-sample" is invalid: spec.local.buckets[0]: Invalid value: "object": path or headers must be set
apiVersion: gateway.kyma-project.io/v1alpha1
kind: RateLimit
metadata:
  labels:
    app: httpbin
  name: ratelimit-header-sample
  namespace: test
spec:
  selectorLabels:
    app: httpbin
  enableResponseHeaders: true
  local:
    defaultBucket:
      maxTokens: 1
      tokensPerFill: 1
      fillInterval: 30s
    buckets:
      - headers:
          X-Rate-Limited: "true"
        path: /headers
        bucket:
          maxTokens: 10
          tokensPerFill: 5
          fillInterval: 30s

This is incorrect behaviour, because this particular bucket example is projected as valid in ADR. See: https://github.com/kyma-project/api-gateway/blob/main/docs/contributor/adr/0011-rate-limit.md#usage-example

The error is in validation rule in

// +kubebuilder:validation:XValidation:rule="((has(self.path)?1:0)+(has(self.headers)?1:0))==1",message="path or headers must be set"
. It only allows either path or headers to be defined.

/kind bug
/area api-gateway

@Ressetkk Ressetkk added the kind/bug Categorizes issue or PR as related to a bug. label Jan 21, 2025
@kyma-bot kyma-bot added the area/api-gateway Issues or PRs related to api-gateway label Jan 21, 2025
@Ressetkk Ressetkk added this to the 2.11.0 milestone Jan 22, 2025
@Ressetkk Ressetkk self-assigned this Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api-gateway Issues or PRs related to api-gateway kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

2 participants