{"record":{"id":"1b53919d50eb91dc","repo":"hashicorp/nomad","slug":"failed-to-encode-bootstrap-command-line-w","errorCode":null,"errorMessage":"failed to encode bootstrap command line: %w","messagePattern":"failed to encode bootstrap command line: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/allocrunner/taskrunner/envoy_bootstrap_hook.go","lineNumber":324,"sourceCode":"\t\th.logger.Error(\"failed to generate envoy bootstrap config\", \"sidecar_for\", service.Name)\n\t\treturn fmt.Errorf(\"failed to generate envoy bootstrap config: %w\", err)\n\t}\n\th.logger.Debug(\"check for SI token for task\", \"task\", req.Task.Name, \"exists\", siToken != \"\")\n\n\tproxyID := h.proxyServiceID(h.alloc.TaskGroup, service)\n\tbootstrap := h.newEnvoyBootstrapArgs(service, grpcAddr, envoyAdminBind, envoyReadyBind, siToken, bootstrapFilePath, proxyID)\n\n\t// Create command line arguments\n\tbootstrapArgs := bootstrap.args()\n\n\t// Write args to file for debugging\n\targsFile, err := os.Create(bootstrapCmdPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to write bootstrap command line: %w\", err)\n\t}\n\tdefer argsFile.Close()\n\tif _, err := io.WriteString(argsFile, strings.Join(bootstrapArgs, \" \")+\"\\n\"); err != nil {\n\t\treturn fmt.Errorf(\"failed to encode bootstrap command line: %w\", err)\n\t}\n\n\t// Create environment\n\tbootstrapEnv := bootstrap.env(h.groupEnv())\n\n\t// Write env to file for debugging\n\tenvFile, err := os.Create(bootstrapEnvPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to write bootstrap environment: %w\", err)\n\t}\n\tdefer envFile.Close()\n\tenvEnc := json.NewEncoder(envFile)\n\tenvEnc.SetIndent(\"\", \"    \")\n\tif err := envEnc.Encode(bootstrapEnv); err != nil {\n\t\treturn fmt.Errorf(\"failed to encode bootstrap environment: %w\", err)\n\t}\n\n\t// keep track of latest error returned from exec-ing consul envoy bootstrap","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/allocrunner/taskrunner/envoy_bootstrap_hook.go#L306-L342","documentation":"After creating the debug command-line file, the hook writes the joined envoy bootstrap arguments via io.WriteString. If the write fails, it returns 'failed to encode bootstrap command line' wrapping the error. This is a debug-artifact write failure inside Prestart of the envoy bootstrap hook.","triggerScenarios":"io.WriteString(argsFile, strings.Join(bootstrapArgs, \" \")+\"\\n\") fails: the file descriptor is broken, disk fills mid-write, or the underlying write syscall returns an I/O error.","commonSituations":"Disk exhaustion during the write; file closed early due to an interleaved error path; rare I/O errors on the client's storage device.","solutions":["Check the wrapped I/O error for ENOSPC or EIO","Free disk space on the client volume","Confirm no other code path closes argsFile before this write","Retry the allocation after resolving storage issues"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// check writability of the debug artifact target before writing\nf, err := os.Create(bootstrapCmdPath)\nif err != nil {\n    return err\n}\nif err := f.Close(); err != nil {\n    return err\n}\nos.Remove(bootstrapCmdPath)","typeGuard":null,"tryCatchPattern":"if err := hook.Prestart(req); err != nil {\n    if strings.Contains(err.Error(), \"failed to encode bootstrap command line\") {\n        log.Printf(\"debug arg-file write failed (I/O): %v\", err)\n        // debug artifact failure; consider tolerating and continuing bootstrap\n    }\n}","preventionTips":["Free disk space proactively on client data volumes","Do not close the argsFile descriptor before the write completes","Consider making debug-artifact failures non-fatal to Prestart","Watch host storage health for EIO conditions"],"tags":["envoy","consul-connect","io"],"backgroundTag":"file-write-failed","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"}