{"record":{"id":"a8e38f737d1bec90","repo":"crowdsecurity/crowdsec","slug":"on-unsupported-security-scheme-w","errorCode":null,"errorMessage":"on_unsupported_security_scheme: %w","messagePattern":"on_unsupported_security_scheme: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/appsec/api_validation/api_validation.go","lineNumber":319,"sourceCode":"func (rv *RequestValidator) LoadSchema(ref string, schema string, opts *SchemaOptions) error {\n\tif ref == \"\" {\n\t\treturn errors.New(\"ref cannot be empty\")\n\t}\n\trv.logger.Debugf(\"loading schema for ref %s\", ref)\n\n\tif _, exists := rv.loaders[ref]; exists {\n\t\treturn fmt.Errorf(\"attempting to load a new schema for existing ref %s\", ref)\n\t}\n\n\toptions := opts.withDefaults()\n\tif err := options.OnRouteNotFound.validate(); err != nil {\n\t\treturn fmt.Errorf(\"on_route_not_found: %w\", err)\n\t}\n\tif err := options.OnMethodNotAllowed.validate(); err != nil {\n\t\treturn fmt.Errorf(\"on_method_not_allowed: %w\", err)\n\t}\n\tif err := options.OnUnsupportedSecurityScheme.validate(); err != nil {\n\t\treturn fmt.Errorf(\"on_unsupported_security_scheme: %w\", err)\n\t}\n\n\tloader := openapi3.NewLoader()\n\trv.loaders[ref] = loader\n\n\tdoc, err := loader.LoadFromData([]byte(schema))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to load schema %s: %w\", ref, err)\n\t}\n\n\t// Is it a valid OpenAPI schema?\n\t// TODO: look into opts, should we expose some of them to the user ?\n\tif err := doc.Validate(loader.Context, openapi3.DisableExamplesValidation()); err != nil {\n\t\treturn fmt.Errorf(\"failed to validate schema %s: %w\", ref, err)\n\t}\n\n\trv.warnUnsupportedSecuritySchemes(ref, doc, options.OnUnsupportedSecurityScheme)\n","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/appsec/api_validation/api_validation.go#L301-L337","documentation":"LoadSchema validates the OnUnsupportedSecurityScheme policy option, which must be exactly \"drop\" or \"ignore\". An invalid value fails options.OnUnsupportedSecurityScheme.validate() and is wrapped as \"on_unsupported_security_scheme: ...\" before any schema parsing happens.","triggerScenarios":"Calling LoadSchema with SchemaOptions.OnUnsupportedSecurityScheme set to anything other than \"drop\"/\"ignore\" (typo, empty string, capitalization), typically from the on_unsupported_security_scheme key in the appsec config.","commonSituations":"Typos in YAML config; assuming other policy strings (e.g. \"log\", \"pass\", \"allow\") are valid; explicit empty-string assignment in code instead of leaving the field zero/unset.","solutions":["Set on_unsupported_security_scheme to exactly \"drop\" or \"ignore\".","Use the PolicyDrop/PolicyIgnore constants in code to avoid string mistakes.","Remove the invalid key from the config so the default applies.","Grep the appsec config for the key and check its exact spelling/case."],"exampleFix":"// before\non_unsupported_security_scheme: pass\n\n// after\non_unsupported_security_scheme: ignore","handlingStrategy":"validation","validationCode":"if p := string(opts.OnUnsupportedSecurityScheme); p != \"drop\" && p != \"ignore\" {\n    return fmt.Errorf(\"bad on_unsupported_security_scheme: %q\", p)\n}","typeGuard":"func isPolicy(s string) bool { return s == \"drop\" || s == \"ignore\" }","tryCatchPattern":"if err := rv.LoadSchema(ref, schema, opts); err != nil {\n    if strings.Contains(err.Error(), \"on_unsupported_security_scheme:\") {\n        log.Errorf(\"fix on_unsupported_security_scheme (drop|ignore): %v\", err)\n    }\n    return err\n}","preventionTips":["Only \"drop\" and \"ignore\" are accepted","Use PolicyDrop/PolicyIgnore constants","Don't invent policy values like \"log\" or \"pass\"","Validate all three policy options together before LoadSchema"],"tags":["appsec","configuration","enum","policy"],"backgroundTag":"invalid-enum-value","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}