{"record":{"id":"dbeb79c9f5aed647","repo":"hashicorp/nomad","slug":"tty-value-is-not-a-boolean-v-dbeb79","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/job_endpoint.go","lineNumber":388,"sourceCode":"\t}\n\n\tsetMeta(resp, &structs.QueryMeta{})\n\n\treturn out.Actions, nil\n}\n\nfunc (s *HTTPServer) jobRunAction(resp http.ResponseWriter, req *http.Request, jobID string) (any, error) {\n\ttask := req.URL.Query().Get(\"task\")\n\taction := req.URL.Query().Get(\"action\")\n\tallocID := req.URL.Query().Get(\"allocID\")\n\n\t// Build the request and parse the ACL token\n\tvar err error\n\tisTTY := false\n\tif tty := req.URL.Query().Get(\"tty\"); tty != \"\" {\n\t\tisTTY, 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\tJobID:   jobID,\n\t\tTask:    task,\n\t\tAction:  action,\n\t\tAllocID: allocID,\n\t\tTty:     isTTY,\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)","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/agent/job_endpoint.go#L370-L406","documentation":"jobRunAction (command/agent/job_endpoint.go:388), reached via JobSpecificRequest for the exec/stream job actions, reads the ?tty= query parameter and parses it with strconv.ParseBool. If the value is non-empty and not a valid Go boolean literal, the request fails with 'tty value is not a boolean'. This rejects the exec request before an allocation is targeted, so no process is started.","triggerScenarios":"GET/POST to the Nomad job exec endpoint (e.g. /v1/client/allocation/... or job exec webSocket route) with ?tty=<bad value> such as tty=yes, tty=on, tty=1.0, or an unexpanded variable. Any non-empty value other than 1/t/T/TRUE/true/True/0/f/F/FALSE/false/False triggers this.","commonSituations":"Hand-rolled websocket/curl commands for nomad alloc exec equivalents using 'yes'/'no'; UI or scripting wrappers passing string flags; query strings built by concatenation where a config variable contains an unexpected string; users copying '?tty=1' typo'd as '?tty=1x'.","solutions":["Set the query parameter to a valid boolean literal: tty=true or tty=false (1/0, t/f also accepted).","Omit the tty parameter entirely when not needed; empty/missing means non-TTY (isTTY=false).","Inspect the %v value in the error to see exactly what string was received and correct the client.","If building requests programmatically, encode the value with strconv.FormatBool(isTTY)."],"exampleFix":"// before\nurl := fmt.Sprintf(\"/v1/job/%s/exec?task=%s&tty=%s\", jobID, task, \"yes\")\n// after\nurl := fmt.Sprintf(\"/v1/job/%s/exec?task=%s&tty=%s\", jobID, task, strconv.FormatBool(true))","handlingStrategy":"validation","validationCode":"// Before issuing the job exec request\nttyStr := strconv.FormatBool(isTTY)\nif _, err := strconv.ParseBool(ttyStr); err != nil {\n    return fmt.Errorf(\"refusing to send invalid tty param %q\", ttyStr)\n}\nurl := fmt.Sprintf(\"...?task=%s&tty=%s\", task, ttyStr)","typeGuard":"func isValidTTYParam(s string) bool {\n    return s == \"true\" || s == \"false\"\n}","tryCatchPattern":"resp, err := http.Post(execURL+\"?tty=\"+ttyStr, \"\", body)\nif err != nil { return err }\nif resp.StatusCode == 400 {\n    // 'tty value is not a boolean' — re-send without the tty param\n    return retryWithoutTTY(execURL, body)\n}","preventionTips":["Build the tty param with strconv.FormatBool, never string interpolation of arbitrary flags.","Use a real bool type in CLI/config plumbing all the way to the URL.","Omit ?tty instead of sending an empty value.","Test exec commands with both tty=true and tty=false once per wrapper script."],"tags":["http","query-parameter","boolean","exec","nomad"],"backgroundTag":"invalid-query-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"}