Skip to content

capture(claudecode): an over-long line reports ErrMalformed where the source is intact #33

Description

@JumpTechCode

parse sets a 16 MiB scanner limit and wraps whatever sc.Err() returns in
port.ErrMalformed. A line longer than the buffer therefore surfaces as
ErrMalformed: bufio.Scanner: token too long.

The source is not damaged. It is recognised and, by this adapter, unreadable —
which is port.ErrUnsupported. The port documents the three sentinels as
reaching different verdicts, and the rule that Assayer's own limits must not
manufacture a regression depends on picking the right one.

Headroom is roughly 4x: the largest line measured in a local store is 4,365,242
bytes, with four lines over 1 MiB.

Two smaller sentinel problems sit beside it:

  • A null line unmarshals into a zero record and is refused as
    ErrUnsupported: unknown record type "", which refuses the whole transcript
    with a misleading reason.
  • A UTF-8 BOM on the first line is refused as ErrMalformed. No file in the
    local store has one; noted for completeness.

Fix

if err := sc.Err(); err != nil {
	if errors.Is(err, bufio.ErrTooLong) {
		return assay.Session{}, fmt.Errorf("%w: %w", port.ErrUnsupported, err)
	}
	return assay.Session{}, fmt.Errorf("%w: %w", port.ErrMalformed, err)
}

Test

A transcript line past the buffer limit must return ErrUnsupported.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcapture-adapterThe Claude Code capture adapter

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions