Skip to content

ABF: raise a clear error on files with an invalid signature#1873

Merged
h-mayorquin merged 2 commits into
NeuralEnsemble:masterfrom
h-mayorquin:improve_axon_error
Jul 13, 2026
Merged

ABF: raise a clear error on files with an invalid signature#1873
h-mayorquin merged 2 commits into
NeuralEnsemble:masterfrom
h-mayorquin:improve_axon_error

Conversation

@h-mayorquin

Copy link
Copy Markdown
Contributor

A file whose header does not start with a valid ABF (Axon Binary Format) signature (b"ABF " or b"ABF2") failed with a cryptic TypeError: 'NoneType' object is not subscriptable deep inside parse_header, because parse_axon_soup returned None for an unrecognized signature and the caller then indexed into it. This now raises a clear NeoReadWriteError naming the file and the unexpected signature, so a caller can tell a corrupt or unsupported file from an actual bug.

I put the error in parse_axon_soup at the point the invalid signature is detected rather than null-checking in the caller, because that is where the signature bytes are available for the message and it makes "an unparseable file always raises" a property of the parser itself. The fixture unparseable_header.abf (a zeroed signature) covers it.

@h-mayorquin h-mayorquin self-assigned this Jul 10, 2026
@h-mayorquin h-mayorquin merged commit 10a1f4b into NeuralEnsemble:master Jul 13, 2026
3 checks 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