Summary
Malformed-header errors from buf curl header files report 0-based line numbers that additionally do not count blank or comment lines, so the reported location drifts away from the real file line.
Reproduction
printf '# comment\nno-colon-here\n' > hdrs.txt
buf curl --http2-prior-knowledge -H @hdrs.txt http://127.0.0.1:9/foo.v1.FooService/Bar
# Failure: hdrs.txt:0: malformed header: "no-colon-here" <- actual file line: 2
(Verified against a local build — the output above is real.)
Root cause
private/buf/bufcurl/headers.go:131-157 — var lineNo int starts at 0 and is incremented only after a successful addHeader; the continue for blank/comment lines never increments it:
var lineNo int
for {
line, err := in.ReadLine()
...
if strings.TrimSpace(line) == "" || strings.HasPrefix(line, "#") {
continue // lineNo not incremented
}
if !addHeader(line, headers) {
return nil, fmt.Errorf("%s:%d: malformed header: %q", headerFile, lineNo, line)
}
lineNo++ // incremented only on success
}
Expected
Increment a 1-based counter on every line read, so file:N matches the editor's line number.
Found via a full mutest (mutation-testing) run over this repo; verified manually.
Summary
Malformed-header errors from
buf curlheader files report 0-based line numbers that additionally do not count blank or comment lines, so the reported location drifts away from the real file line.Reproduction
(Verified against a local build — the output above is real.)
Root cause
private/buf/bufcurl/headers.go:131-157—var lineNo intstarts at 0 and is incremented only after a successfuladdHeader; thecontinuefor blank/comment lines never increments it:Expected
Increment a 1-based counter on every line read, so
file:Nmatches the editor's line number.Found via a full mutest (mutation-testing) run over this repo; verified manually.