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.
parsesets a 16 MiB scanner limit and wraps whateversc.Err()returns inport.ErrMalformed. A line longer than the buffer therefore surfaces asErrMalformed: 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 asreaching 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:
nullline unmarshals into a zerorecordand is refused asErrUnsupported: unknown record type "", which refuses the whole transcriptwith a misleading reason.
ErrMalformed. No file in thelocal store has one; noted for completeness.
Fix
Test
A transcript line past the buffer limit must return
ErrUnsupported.