{"record":{"id":"e32cefc6a11ca98f","repo":"crowdsecurity/crowdsec","slug":"schema-option-q-must-be-a-string-got-t","errorCode":null,"errorMessage":"schema option %q must be a string, got %T","messagePattern":"schema option %q must be a string, got %T","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/appsec/appsec.go","lineNumber":1923,"sourceCode":"}\n\n// RegisterAPISchemaBodyDecoder allows a user's on_load hook to add a Content-Type\n// to the set the API schema validator can decode. decoderName must be one of\n// the stable built-in identifiers exported by the api_validation package\n// (\"json\", \"urlencoded\", \"multipart\", \"yaml\", \"csv\", \"plain\", \"file\"). Note\n// that the underlying kin-openapi decoder registry is process-global: today\n// all appsec datasources in the same process share the same set of\n// registered body decoders.\nfunc (w *AppsecRuntimeConfig) RegisterAPISchemaBodyDecoder(contentType, decoderName string) error {\n\treturn w.RequestValidator.RegisterBodyDecoder(contentType, decoderName)\n}\n\nfunc parseSchemaOptions(opts map[string]any) (*apivalidation.SchemaOptions, error) {\n\tout := &apivalidation.SchemaOptions{}\n\tfor k, v := range opts {\n\t\ts, ok := v.(string)\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"schema option %q must be a string, got %T\", k, v)\n\t\t}\n\t\tswitch k {\n\t\tcase \"on_route_not_found\":\n\t\t\tout.OnRouteNotFound = apivalidation.Policy(s)\n\t\tcase \"on_method_not_allowed\":\n\t\t\tout.OnMethodNotAllowed = apivalidation.Policy(s)\n\t\tcase \"on_unsupported_security_scheme\":\n\t\t\tout.OnUnsupportedSecurityScheme = apivalidation.Policy(s)\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"unknown schema option %q\", k)\n\t\t}\n\t}\n\treturn out, nil\n}\n\n// validationErrorVarKeys lists the keys published into state.HookVars by\n// ValidateRequestWithSchema. Keeping them centralized makes it easy to reset\n// them all at the start of each validation call.","sourceCodeStart":1905,"sourceCodeEnd":1941,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/appsec/appsec.go#L1905-L1941","documentation":"parseSchemaOptions received a non-string value for a named appsec schema option (on_route_not_found, on_method_not_allowed, on_unsupported_security_scheme). All recognized options are string policies, so any other Go type (number, bool, map) means the config layer passed a wrongly-typed option value; %T shows the actual type.","triggerScenarios":"Thrown at pkg/appsec/appsec.go:1923 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the appsec config: schema options like on_route_not_found must be quoted strings (\"drop\" or \"ignore\")","Check for YAML quoting issues — a bare value parsed as a non-string lands here"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}