{"record":{"id":"d7415565fe697008","repo":"hibiken/asynq","slug":"asynq-unsupported-log-level-q","errorCode":null,"errorMessage":"asynq: unsupported log level %q","messagePattern":"asynq: unsupported log level %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server.go","lineNumber":378,"sourceCode":"\t}\n\tpanic(fmt.Sprintf(\"asynq: unexpected log level: %v\", *l))\n}\n\n// Set is part of the flag.Value interface.\nfunc (l *LogLevel) Set(val string) error {\n\tswitch strings.ToLower(val) {\n\tcase \"debug\":\n\t\t*l = DebugLevel\n\tcase \"info\":\n\t\t*l = InfoLevel\n\tcase \"warn\", \"warning\":\n\t\t*l = WarnLevel\n\tcase \"error\":\n\t\t*l = ErrorLevel\n\tcase \"fatal\":\n\t\t*l = FatalLevel\n\tdefault:\n\t\treturn fmt.Errorf(\"asynq: unsupported log level %q\", val)\n\t}\n\treturn nil\n}\n\nfunc toInternalLogLevel(l LogLevel) log.Level {\n\tswitch l {\n\tcase DebugLevel:\n\t\treturn log.DebugLevel\n\tcase InfoLevel:\n\t\treturn log.InfoLevel\n\tcase WarnLevel:\n\t\treturn log.WarnLevel\n\tcase ErrorLevel:\n\t\treturn log.ErrorLevel\n\tcase FatalLevel:\n\t\treturn log.FatalLevel\n\t}\n\tpanic(fmt.Sprintf(\"asynq: unexpected log level: %v\", l))","sourceCodeStart":360,"sourceCodeEnd":396,"githubUrl":"https://github.com/hibiken/asynq/blob/d135f1439bee74e989b7f9b41ecd542cc87f024a/server.go#L360-L396","documentation":"This error is returned by SetLogLevel (via the internal toLogLevel parser) in asynq when the supplied log level string does not match one of the recognized levels (debug, info, warn, error, fatal). The library validates the string strictly case-insensitively against its enum and refuses any unknown value. It is a guard against silently running with an undefined logging configuration.","triggerScenarios":"Calling srv.SetLogLevel(\"verbose\"), SetLogLevel(\"WARNING\"), or any string outside {debug, info, warn, error, fatal}; passing a log level read from an environment variable or config file that asynq does not recognize.","commonSituations":"Operators configure ASYNQ_LOG_LEVEL or a YAML config with values like \"trace\", \"warning\", or \"none\"; typos in deployment configs; migrating from another logging library whose level names differ.","solutions":["Change the log level string to one of: debug, info, warn, error, fatal.","Validate the configured value against the allowed set before calling SetLogLevel.","Lowercase and trim the input string if it may come from env/config with casing or whitespace.","If using SetLogLevel, prefer asynq.LogLevel(...) or the built-in constants to avoid string typing."],"exampleFix":"// before\nsrv.SetLogLevel(\"WARNING\")\n// after\nsrv.SetLogLevel(\"warn\") // allowed: \"debug\",\"info\",\"warn\",\"error\",\"fatal\"","handlingStrategy":"validation","validationCode":"var validLevels = map[string]bool{\"debug\":true,\"info\":true,\"warn\":true,\"error\":true,\"fatal\":true}\nif !validLevels[strings.ToLower(strings.TrimSpace(cfg.LogLevel))] {\n    return fmt.Errorf(\"invalid log level %q; must be one of debug,info,warn,error,fatal\", cfg.LogLevel)\n}\nsrv.SetLogLevel(strings.ToLower(cfg.LogLevel))","typeGuard":null,"tryCatchPattern":"if err := srv.SetLogLevel(level); err != nil {\n    log.Fatalf(\"bad log level: %v\", err)\n}","preventionTips":["Keep a whitelist constant of allowed asynq log levels and validate env/config input against it.","Normalize casing/whitespace before calling SetLogLevel.","Use the debug/info/warn/error/fatal string literals consistently across services."],"tags":["go","asynq","logging","configuration"],"backgroundTag":"invalid-enum-value","analyzedSha":"d135f1439bee74e989b7f9b41ecd542cc87f024a","analyzedAt":"2026-09-07T19:02:34.660Z","contentChangedAt":"2026-09-07T19:02:34.660Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}