ipfs/kubo · error

offset was past end of file (%d > %d)

Error message

offset was past end of file (%d > %d)

What it means

'ipfs files read': the requested --offset exceeds the file's size (%d > %d), so the read would start past EOF and return nothing meaningful; the command rejects it up front after querying the MFS file's size.

Source

Thrown at core/commands/files.go:872

		rfd, err := fi.Open(req.Context, mfs.Flags{Read: true})
		if err != nil {
			return err
		}

		defer rfd.Close()

		offset, _ := req.Options[offsetOptionName].(int64)
		if offset < 0 {
			return fmt.Errorf("cannot specify negative offset")
		}

		filen, err := rfd.Size()
		if err != nil {
			return err
		}

		if int64(offset) > filen {
			return fmt.Errorf("offset was past end of file (%d > %d)", offset, filen)
		}

		_, err = rfd.Seek(int64(offset), io.SeekStart)
		if err != nil {
			return err
		}

		var r io.Reader = &contextReaderWrapper{R: rfd, ctx: req.Context}
		count, found := req.Options[filesCountOptionName].(int64)
		if found {
			if count < 0 {
				return fmt.Errorf("cannot specify negative 'count'")
			}
			r = io.LimitReader(r, int64(count))
		}
		return res.Emit(r)
	},
}

View on GitHub (pinned to 329838acdf)

Solutions

  1. Use an offset smaller than the file size (check with 'ipfs files stat <path>')
  2. Combine with --count to bound the read length
  3. Drop the offset to read the whole file
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at core/commands/files.go:872 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03). Data as JSON: /api/errors/b12867c6e6ad4e37. Report an issue: GitHub.