{"record":{"id":"726b4eebe7c03ed0","repo":"hashicorp/nomad","slug":"tty-value-is-not-a-boolean-v","errorCode":null,"errorMessage":"tty value is not a boolean: %v","messagePattern":"tty value is not a boolean: (.+?)","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"command/agent/alloc_endpoint.go","lineNumber":604,"sourceCode":"\treturn reply.Results, rpcErr\n}\n\nfunc (s *HTTPServer) allocExec(allocID string, resp http.ResponseWriter, req *http.Request) (any, error) {\n\t// Build the request and parse the ACL token\n\ttask := req.URL.Query().Get(\"task\")\n\tcmdJsonStr := req.URL.Query().Get(\"command\")\n\tvar command []string\n\terr := json.Unmarshal([]byte(cmdJsonStr), &command)\n\tif err != nil {\n\t\t// this shouldn't happen, []string is always be serializable to json\n\t\treturn nil, fmt.Errorf(\"failed to marshal command into json: %v\", err)\n\t}\n\n\tttyB := false\n\tif tty := req.URL.Query().Get(\"tty\"); tty != \"\" {\n\t\tttyB, err = strconv.ParseBool(tty)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"tty value is not a boolean: %v\", err)\n\t\t}\n\t}\n\n\targs := cstructs.AllocExecRequest{\n\t\tAllocID: allocID,\n\t\tTask:    task,\n\t\tCmd:     command,\n\t\tTty:     ttyB,\n\t}\n\ts.parse(resp, req, &args.QueryOptions.Region, &args.QueryOptions)\n\n\tconn, err := s.getWebsocketConnection(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn s.execStream(conn, &args)\n}","sourceCodeStart":586,"sourceCodeEnd":622,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/agent/alloc_endpoint.go#L586-L622","documentation":"This error is raised by allocExec in command/agent/alloc_endpoint.go:604 when the `tty` query parameter of the exec endpoint is present but strconv.ParseBool cannot parse it. ParseBool only accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False, so any other value (e.g. \"yes\", \"on\", \"1 \" with whitespace, or an empty-but-present parameter after intermediary rewriting) fails.","triggerScenarios":"Calling GET /v1/client/allocation/<allocID>/exec with a non-empty `tty` query parameter that is not a Go-recognized boolean literal — e.g. tty=yes, tty=on, tty=2, or tty=%20 (whitespace).","commonSituations":"Tooling using shell-style yes/no flags against the Nomad HTTP API; URL builders appending tty with a formatted non-bool value; hand-written clients assuming a wider accepted boolean set than ParseBool supports.","solutions":["Send only values strconv.ParseBool accepts: true/false, 1/0, t/f, T/F, TRUE/FALSE, True/False.","Coerce your client's boolean to a canonical 'true'/'false' string before building the query string.","Omit the tty parameter entirely when no TTY is desired (absence defaults to false).","Check for accidental whitespace or duplicated parameters (tty=true&tty=yes) in the URL."],"exampleFix":"// before: shell-style boolean\nurl := fmt.Sprintf(\".../exec?allocID=%s&task=%s&command=%s&tty=%v\", allocID, task, cmd, \"yes\")\n// after: canonical bool string\nurl := fmt.Sprintf(\".../exec?allocID=%s&task=%s&command=%s&tty=%t\", allocID, task, cmd, wantTTY)","handlingStrategy":"validation","validationCode":"if _, err := strconv.ParseBool(ttyParam); err != nil {\n    return fmt.Errorf(\"tty must be a ParseBool-compatible bool, got %q\", ttyParam)\n}","typeGuard":"func isParseBool(s string) bool {\n    _, err := strconv.ParseBool(s)\n    return err == nil\n}","tryCatchPattern":null,"preventionTips":["Serialize booleans with %t or strconv.FormatBool, never shell-style yes/no strings.","Omit the tty parameter when false; only append it when TTY is requested.","Sanitize inputs for stray whitespace before placing them in query strings.","Remember only 1/0, t/f, true/false (and case variants) are accepted by Go's strconv.ParseBool."],"tags":["nomad","http-api","query-parameters","boolean-parsing","exec"],"backgroundTag":"invalid-boolean-parameter","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"}