{"record":{"id":"99ae76bfc4f78617","repo":"projectdiscovery/nuclei","slug":"invalid-useragent-s","errorCode":null,"errorMessage":"Invalid userAgent: %s","messagePattern":"Invalid userAgent: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/model/types/userAgent/user_agent.go","lineNumber":48,"sourceCode":"\tCustom:  \"custom\",\n}\n\nfunc GetSupportedUserAgentOptions() []UserAgent {\n\tvar result []UserAgent\n\tfor index := UserAgent(1); index < limit; index++ {\n\t\tresult = append(result, index)\n\t}\n\treturn result\n}\n\nfunc toUserAgent(valueToMap string) (UserAgent, error) {\n\tnormalizedValue := normalizeValue(valueToMap)\n\tfor key, currentValue := range userAgentMappings {\n\t\tif normalizedValue == currentValue {\n\t\t\treturn key, nil\n\t\t}\n\t}\n\treturn -1, errors.New(\"Invalid userAgent: \" + valueToMap)\n}\n\nfunc normalizeValue(value string) string {\n\treturn strings.TrimSpace(strings.ToLower(value))\n}\n\nfunc (userAgent UserAgent) String() string {\n\treturn userAgentMappings[userAgent]\n}\n\n// UserAgentHolder holds a UserAgent type. Required for un/marshalling purposes\ntype UserAgentHolder struct {\n\tValue UserAgent `mapping:\"true\"`\n}\n\nfunc (userAgentHolder UserAgentHolder) JSONSchema() *jsonschema.Schema {\n\tgotType := &jsonschema.Schema{\n\t\tType:        \"string\",","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/model/types/userAgent/user_agent.go#L30-L66","documentation":"Raised by toUserAgent when a UserAgentHolder is unmarshalled from YAML/JSON and the normalized value (TrimSpace + ToLower) is not in userAgentMappings. The only accepted values are 'random', 'off', 'default' and 'custom' (user_agent.go:26-31). It fires during config/template load, so it fails fast before any request is sent.","triggerScenarios":"Setting a user-agent mode field to 'browser', 'mozilla', 'none' or an arbitrary UA string where the enum (random|off|default|custom) is expected.","commonSituations":"Confusing the mode enum with the actual UA string (the string belongs in a different field once mode is 'custom'); porting configs from other scanners with different option names.","solutions":["Use one of the four allowed values: random, off, default, custom","Put the actual browser string in the dedicated custom UA field, not in the mode enum","Validate the config file with nuclei -validate before a run"],"exampleFix":"# before\nuser-agent: Mozilla/5.0 (compat)\n# after\nuser-agent: custom\n# and set the custom string in the dedicated field it drives","handlingStrategy":"validation","validationCode":"var validUserAgents = map[string]bool{\"random\": true, \"off\": true, \"default\": true, \"custom\": true}\nfunc userAgentOK(s string) bool { return validUserAgents[strings.ToLower(strings.TrimSpace(s))] }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the mode enum and the custom UA string in separate config fields","Document the four allowed values wherever configs are generated"],"tags":["user-agent","config","yaml","validation"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}