{"record":{"id":"f6900b8642b1ee0f","repo":"hashicorp/nomad","slug":"error-reading-file-v-f6900b","errorCode":null,"errorMessage":"error reading file: %v","messagePattern":"error reading file: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/alloc_logs.go","lineNumber":280,"sourceCode":"\t\t\tlogType = api.FSLogNameStderr\n\t\t}\n\t\tif err := l.handleSingleFile(client, alloc, logType); err != nil {\n\t\t\tl.Ui.Error(fmt.Sprintf(\"Failed to read %s file: %v\", logType, err))\n\t\t\treturn 1\n\t\t}\n\t}\n\n\treturn 0\n}\n\nfunc (l *AllocLogsCommand) handleSingleFile(client *api.Client, alloc *api.Allocation, logType string) error {\n\t// We have a file, output it.\n\tvar r io.ReadCloser\n\tvar readErr error\n\tif !l.tail {\n\t\tr, readErr = l.followFile(client, alloc, logType, api.OriginStart, 0)\n\t\tif readErr != nil {\n\t\t\treturn fmt.Errorf(\"error reading file: %v\", readErr)\n\t\t}\n\t} else {\n\t\t// Parse the offset\n\t\tvar offset = defaultTailLines * bytesToLines\n\n\t\tif nLines, nBytes := l.numLines != -1, l.numBytes != -1; nLines && nBytes {\n\t\t\treturn errors.New(\"both -n and -c set\")\n\t\t} else if nLines {\n\t\t\toffset = l.numLines * bytesToLines\n\t\t} else if nBytes {\n\t\t\toffset = l.numBytes\n\t\t} else {\n\t\t\tl.numLines = defaultTailLines\n\t\t}\n\n\t\tr, readErr = l.followFile(client, alloc, logType, api.OriginEnd, offset)\n\n\t\t// If numLines is set, wrap the reader","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/alloc_logs.go#L262-L298","documentation":"Fires in handleSingleFile when not tailing: the initial followFile call to stream the allocation's stdout/stderr from the client failed (API error, unavailable client, or missing file).","triggerScenarios":"Thrown at command/alloc_logs.go:280 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the allocation and task exist and have produced logs","Check client connectivity and allocation state","Retry on transient streaming errors"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}