Skip to content

Fix headerless channel decoding of extra columns - #306

Merged
pikanezi merged 1 commit into
gocarina:masterfrom
bensynapse:fix-headerless-channel-extra-columns
Oct 12, 2026
Merged

pikanezi merged 1 commit into
gocarina:masterfrom
bensynapse:fix-headerless-channel-extra-columns

Conversation

@bensynapse

Copy link
Copy Markdown
Contributor

I run Live Tennis API.

UnmarshalToChanWithoutHeaders panics when a row has more columns than the destination struct.
For example, a row containing first,1,ignored panics when decoding a struct with two CSV fields.
UnmarshalWithoutHeaders already ignores the extra column after #287.

This applies the same bounds check to the channel decoder.
Tests cover value and pointer records, nested pointer fields and quoted extra columns.
They also check shorter rows, conversion errors and reader errors.
The four extra column cases panic before the fix.

Checked with go test -v ./... on Go 1.21.13 and 1.23.4.
go test -race ./..., go build -v ./... and go vet ./... pass on Go 1.23.4.
Go 1.13.15 cannot compile types.go because it calls reflect.Value.SetZero.
Untouched master has the same compilation error.

Match headerless slice decoding when rows contain more columns than the
destination struct.
@pikanezi

Copy link
Copy Markdown
Member

Thanks

@pikanezi
pikanezi merged commit a78f660 into gocarina:master Oct 12, 2026
1 check passed
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.

2 participants