Skip to content

fix(golangci): treat empty stdout as no-issues and surface stderr#189

Merged
notJoon merged 1 commit into
mainfrom
fix/golangci-empty-output
Apr 27, 2026
Merged

fix(golangci): treat empty stdout as no-issues and surface stderr#189
notJoon merged 1 commit into
mainfrom
fix/golangci-empty-output

Conversation

@notJoon

@notJoon notJoon commented Apr 27, 2026

Copy link
Copy Markdown
Member

Summary

  • Stop emitting decode golangci-lint output: unexpected end of JSON input warnings for every .gno file in a package.
  • golangci-lint exits with empty stdout when go/packages cannot load the target (the common case is a pure-.gno directory whose temp .go file imports gno.land/... paths the standard Go loader cannot resolve). The previous code passed that empty body to json.Unmarshal, which failed and the engine logged a warn per file.
  • Short-circuit empty (or whitespace-only) stdout to a zero result with no error. Capture stderr separately and embed a truncated snippet in the wrapped error so real decode failures stay diagnosable.
  • Extract parsing into decodeGolangciOutput so empty / valid / malformed branches are unit-testable without spawning the binary.

Repro

CI on a pure-.gno repo (e.g. gnoswap-labs/gnoswap run 24982317573) shows hundreds of decode golangci-lint output for <dir>: unexpected end of JSON input warnings — one per .gno file. After this change those warnings disappear; real decode failures still surface with the stderr snippet attached.

Test plan

  • go build ./...
  • make test (race + shuffle) — all packages pass
  • Bench: go test -bench=BenchmarkRun -benchmem -run=^$ -benchtime=3x ./internal/ within ±5% of main
  • New default_golangci_test.go: empty / valid / malformed JSON for decodeGolangciOutput, plus 6 cases for snippet
  • Re-run tlin against gnoswap and confirm the per-file warnings are gone

Follow-up

A separate PR will wire GOPACKAGESDRIVER=gnopls so golangci-lint can actually analyze .gno packages instead of producing empty output.

golangci-lint exits with empty stdout when go/packages cannot load
the target — typically a .gno-only directory whose temp .go file
imports gno.land/... paths the standard Go loader cannot resolve.
Previously the empty body was passed to json.Unmarshal, which failed
with "unexpected end of JSON input"; the engine then logged a warn
per file in such a package and dominated the CI log.

Short-circuit empty (or whitespace-only) stdout to a zero result
with no error, and capture stderr separately so a real decode
failure carries a truncated stderr snippet for diagnosis. Extract
the parsing into decodeGolangciOutput so the empty / valid /
malformed branches are unit-testable without spawning the binary.
@notJoon notJoon merged commit 12ef405 into main Apr 27, 2026
6 checks passed
@notJoon notJoon deleted the fix/golangci-empty-output branch April 27, 2026 13:11
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.

1 participant