{"record":{"id":"3e79f03a411dbc99","repo":"hashicorp/nomad","slug":"unknown-log-level-3e79f0","errorCode":null,"errorMessage":"Unknown log level","messagePattern":"Unknown log level","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"nomad/client_agent_endpoint.go","lineNumber":164,"sourceCode":"\t\treturn\n\t}\n\n\t// Check agent read permissions\n\tif aclObj, err := a.srv.ResolveACL(&args); err != nil {\n\t\thandleStreamResultError(err, nil, encoder)\n\t\treturn\n\t} else if !aclObj.AllowAgentRead() {\n\t\thandleStreamResultError(structs.ErrPermissionDenied, new(int64(403)), encoder)\n\t\treturn\n\t}\n\n\tlogLevel := log.LevelFromString(args.LogLevel)\n\tif args.LogLevel == \"\" {\n\t\tlogLevel = log.LevelFromString(\"INFO\")\n\t}\n\n\tif logLevel == log.NoLevel {\n\t\thandleStreamResultError(errors.New(\"Unknown log level\"), new(int64(400)), encoder)\n\t\treturn\n\t}\n\n\t// Targeting a node, forward request to node\n\tif args.NodeID != \"\" {\n\t\ta.forwardMonitorClient(conn, args, encoder, decoder, args.NodeID, \"Agent.Monitor\")\n\t\t// forwarded request has ended, return\n\t\treturn\n\t}\n\n\tregion := args.RequestRegion()\n\tif region == \"\" {\n\t\thandleStreamResultError(fmt.Errorf(\"missing target region\"), new(int64(400)), encoder)\n\t\treturn\n\t}\n\tif region != a.srv.Region() {\n\t\t// Mark that we are forwarding\n\t\targs.SetForwarded()","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/client_agent_endpoint.go#L146-L182","documentation":"The Agent.Monitor endpoint parses args.LogLevel with go-hclog's LevelFromString; an unparsable level yields log.NoLevel, and the monitor rejects the request with this 400 stream error before forwarding to the node.","triggerScenarios":"Calling Agent.Monitor (server or `nomad monitor`) with LogLevel set to a string that is not one of TRACE, DEBUG, INFO, WARN, ERROR (case-insensitive) — e.g. \"verbose\", \"warning\", \"err\", or a typo.","commonSituations":"Scripts passing arbitrary log-level flags from user input; using \"warning\" instead of \"warn\"; using \"fatal\" which go-hclog does not map here; empty handling only covers \"\", any other bad string fails.","solutions":["Set LogLevel to one of the exact go-hclog levels: TRACE, DEBUG, INFO, WARN, or ERROR.","Replace \"warning\" with \"WARN\" and \"err\"/\"fatal\" with \"ERROR\" in scripts or CLI flags.","Validate/sanitize the log level in wrapper tooling before invoking Agent.Monitor.","If the level is unknown, omit it entirely — an empty LogLevel defaults to INFO."],"exampleFix":"// before\nargs := &api.MonitorOpts{LogLevel: \"warning\"}\n// after\nargs := &api.MonitorOpts{LogLevel: \"WARN\"}","handlingStrategy":"validation","validationCode":"var validLevels = map[string]bool{\"TRACE\": true, \"DEBUG\": true, \"INFO\": true, \"WARN\": true, \"ERROR\": true}\nif opts.LogLevel != \"\" && !validLevels[strings.ToUpper(opts.LogLevel)] {\n    return fmt.Errorf(\"invalid log level %q; use TRACE|DEBUG|INFO|WARN|ERROR\", opts.LogLevel)\n}","typeGuard":null,"tryCatchPattern":"err := client.Agent().Monitor(ctx, opts, fn)\nif err != nil && strings.Contains(err.Error(), \"Unknown log level\") {\n    opts.LogLevel = \"INFO\" // fall back to default and retry\n}","preventionTips":["Only pass go-hclog level names: TRACE, DEBUG, INFO, WARN, ERROR.","Normalize \"warning\"→\"WARN\" and \"fatal\"→\"ERROR\" in wrapper scripts.","Leave LogLevel empty when in doubt; it defaults to INFO."],"tags":["logging","validation","monitor","bad-request"],"backgroundTag":"invalid-log-level","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}