Skip to content

Read a requirements.txt line longer than 64 KiB instead of failing the scan with "bufio.Scanner: token too long" (#50) - #52

Merged
thebenignhacker merged 1 commit into
mainfrom
integrate/2026-10-17-r12
Oct 17, 2026
Merged

thebenignhacker merged 1 commit into
mainfrom
integrate/2026-10-17-r12

Conversation

@thebenignhacker

Copy link
Copy Markdown
Member

This pull request lands 1 commit in internal/manifest and CHANGELOG.md.

Included

Verified on this exact tree

  • go build ./...: exit 0
  • go vet ./...: exit 0
  • gofmt -l cmd internal pkg: no files listed
  • golangci-lint run ./... (golangci-lint 2.12.2): exit 3, can't load config: unsupported version of the configuration: ""
  • golangci-lint run -c <copy of .golangci.yml converted by golangci-lint migrate> ./...: 8 issues (staticcheck: 8); the same command on origin/main (09d9c66): 8 issues (staticcheck: 8), the same 8 check IDs in the same files
  • Changelog check: none in the repository
  • go test -json -race -p 4 -count=1 -coverprofile=<temporary file> ./...: exit 0; 16 packages, 13 ok and 3 with no test files
  • Top-level tests from that run: 520 passed, 1 skipped, 0 failed
  • Tests including subtests from that run: 1604 passed, 1 skipped, 0 failed
  • Skipped: TestIntegration_FetchPyPIPackage (internal/analyzer/source), output pip not available, skipping test

Not included

None

Closes

Fixes #50

How to merge

Rebase and merge, so that each change stays its own commit on main.

…e scan with "bufio.Scanner: token too long" (#50)

The requirements.txt reader, which both the dependency parser and the
unread-lines reader use, read the file with a bufio.Scanner and its default
token limit of 64 KiB. A longer line stopped it with "bufio.Scanner: token
too long", the parser returned that error, and the file was refused as a
whole: a directory whose requirements.txt has a first line of
"cryptography==42.0.0 " followed by 70,000 "x" characters failed
analyze --offline with "found 1 manifest file(s) but none could be read" and
exit code 2. pip 26.0's requirements reader reads that 70,021-character line
and the lines after it. The scanner's token limit is now math.MaxInt.

With "pycryptodome==3.20.0" and "-r extra.txt" after the long line,
analyze --offline now reports 2 dependencies, lists line 3 as an include it
did not follow, and exits 1. The x characters stay in the version
cryptography is reported with (cryptography@42.0.0 xxx...), as trailing text
on a short line does before and after this change. For
testdata/fixtures/python-project the table output and stderr are the same
before and after, the JSON output differs only in timestamps, and the exit
code is 1 for both.

Fixes #50
@thebenignhacker
thebenignhacker merged commit 93be0e5 into main Oct 17, 2026
3 checks passed
@thebenignhacker
thebenignhacker deleted the integrate/2026-10-17-r12 branch October 17, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A requirements.txt line longer than 64 KiB makes the scan fail with bufio.Scanner: token too long

1 participant