hashicorp/nomad · error

error reading file: %v

Error message

error reading file: %v

What it means

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).

Source

Thrown at command/alloc_logs.go:280

			logType = api.FSLogNameStderr
		}
		if err := l.handleSingleFile(client, alloc, logType); err != nil {
			l.Ui.Error(fmt.Sprintf("Failed to read %s file: %v", logType, err))
			return 1
		}
	}

	return 0
}

func (l *AllocLogsCommand) handleSingleFile(client *api.Client, alloc *api.Allocation, logType string) error {
	// We have a file, output it.
	var r io.ReadCloser
	var readErr error
	if !l.tail {
		r, readErr = l.followFile(client, alloc, logType, api.OriginStart, 0)
		if readErr != nil {
			return fmt.Errorf("error reading file: %v", readErr)
		}
	} else {
		// Parse the offset
		var offset = defaultTailLines * bytesToLines

		if nLines, nBytes := l.numLines != -1, l.numBytes != -1; nLines && nBytes {
			return errors.New("both -n and -c set")
		} else if nLines {
			offset = l.numLines * bytesToLines
		} else if nBytes {
			offset = l.numBytes
		} else {
			l.numLines = defaultTailLines
		}

		r, readErr = l.followFile(client, alloc, logType, api.OriginEnd, offset)

		// If numLines is set, wrap the reader

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Verify the allocation and task exist and have produced logs
  2. Check client connectivity and allocation state
  3. Retry on transient streaming errors
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at command/alloc_logs.go:280 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/f6900b8642b1ee0f. Report an issue: GitHub.