Middleware Parsing Issue?

I have the following Router defined for the Traefik dashboard and it's using the BasicAuth middleware. It seems to have worked at times, but it's not consistent and I cannot tell what the issue is.

Router:

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: traefik-dashboard
  namespace: <namespace>
  labels:
    app: traefik
spec:
  routes:
    - match: PathPrefix(`/dashboard`) || PathPrefix(`/api`)
      kind: Rule
      services:
        - name: api@internal
          kind: TraefikService
      middlewares:
        - auth

BasicAuth:

apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: auth
  namespace: <namespace>
spec:
  basicAuth:
    secret: traefik-admin

Error:

tools/cache/reflector.go:98: Failed to list *v1alpha1.IngressRoute: v1alpha1.IngressRouteList.Items: []v1alpha1.IngressRoute: v1alpha1.IngressRoute.Spec: v1alpha1.IngressRouteSpec.Routes: []v1alpha1.Route: v1alpha1.Route.Middlewares: []v1alpha1.MiddlewareRef: readObjectStart: expect { or n, but found ", error found in #10 byte of ...|ewares":["auth"],"se|..., bigger context ...|ashboard`) || PathPrefix(`/api`)","middlewares":["auth"],"services":[{"kind":"TraefikService","name"|..

Hello @krg7880,

Checking with the reference documentation: (https://docs.traefik.io/reference/dynamic-configuration/kubernetes-crd/)

Middlewares expects a name key:

      middlewares:
        - name: stripprefix

Which is why your error is expecting an opening brace or the letter n :wink:

Let us know if adding that key works for you.

Perfect - That worked! Plain oversight on my part.