mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-10-14 04:07:46 +00:00
fix(catalog): analyzer-valid testData and explicit New() error return
The plugin catalog analyzer failed v1.0.28 with "invalid handler type: <nil>" (#151). Two defects combined. The analyzer feeds .traefik.yml testData to New() verbatim. The header values used quadruple braces on a false premise: no configuration path collapses them. Template validation rejected them, so New() failed. The testData now carries plain, valid templates. New() also returned failures through a multi-value tail call (return NewWithContext(...)). Yaegi v0.16.1 zeroes both results of that statement on the error path. The analyzer therefore saw (nil, nil) and reported the opaque handler-type message instead of the real validation error. New() now splits the return explicitly. Construction failures surface as real error messages under yaegi and in Traefik logs. The regression tests pin both fixes. README and CONFIGURATION.md now give correct escaping guidance: plain double braces everywhere; file provider users escape with a raw string. Quadruple braces do not work anywhere. Fixes #151.
This commit is contained in:
@@ -136,7 +136,20 @@ func New(ctx context.Context, next http.Handler, config *Config, name string) (h
|
||||
telemetry.Send("traefikoidc", traefikoidcPluginVersion)
|
||||
}
|
||||
})
|
||||
return NewWithContext(ctx, config, next, name)
|
||||
// Deliberately NOT `return NewWithContext(...)` (issue #151): that tail call
|
||||
// converts (*TraefikOidc, error) to (http.Handler, error) in the return
|
||||
// statement. Compiled, a failed construction then returns a typed-nil
|
||||
// *TraefikOidc wrapped in a NON-nil http.Handler; under yaegi v0.16.1 (the
|
||||
// interpreter Traefik and the plugin-catalog analyzer embed) the same
|
||||
// statement zeroes BOTH results on the error path, so callers saw
|
||||
// (nil, nil) and reported the opaque "invalid handler type: <nil>" instead
|
||||
// of the real error. The explicit split returns an untyped nil handler and
|
||||
// keeps the error intact in both worlds.
|
||||
t, err := NewWithContext(ctx, config, next, name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return t, nil
|
||||
}
|
||||
|
||||
// NewWithContext creates a new TraefikOidc middleware instance with proper context handling.
|
||||
|
||||
Reference in New Issue
Block a user