Thanks to visit codestin.com
Credit goes to github.com

Skip to content

more distinct miniseed read errors, print zero size instead of unknown format - #3721

Open
filefolder wants to merge 5 commits into
obspy:masterfrom
filefolder:extra_miniseed_errors
Open

more distinct miniseed read errors, print zero size instead of unknown format#3721
filefolder wants to merge 5 commits into
obspy:masterfrom
filefolder:extra_miniseed_errors

Conversation

@filefolder

Copy link
Copy Markdown
Contributor

What does this PR do?

the "Invalid MiniSEED file" error messages are often a bit too vague to determine what is happening (e.g. #3549). Now expanded somewhat.

Also catches the read in base.py-- after all attempts to determine format it will finally check if the file is zero before printing the "unknown format".

on master

AI used?

for sanity washing

@filefolder filefolder added the ready for review PRs that are ready to be reviewed to get marked ready to merge label Mar 27, 2026
# create empty file
open(tmpfile, 'wb').close()
# create small non-empty file
open(tmpfile, 'wb').write(b'\x82\x00\x00')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@filefolder you're changing the behaviour here ? I see the change in base.py is raising a ValueError when the file is empty, but the pytest below only checks TypeError, no?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, has to be reverted, this is an intentional test for empty files clearly.

Comment thread obspy/io/mseed/util.py
else:
raise ValueError("Invalid MiniSEED file.")
raise ValueError("Invalid MiniSEED file: "
"unexpected content in noise record.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noise?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ha I don't actually know. the comment for that block is # Might be a noise record or completely empty. and I continued on with that just to better isolate where the failure was happening. IIRC the whole point to this PR is just to narrow down what's actually causing the error.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But, you clearly did this for an unclear error you encountered right? So what was the actual problem in your case? Was it a noise record?

@ThomasLecocq ThomasLecocq added this to the 1.5.1 milestone Aug 24, 2026
@ThomasLecocq ThomasLecocq added author action needed and removed ready for review PRs that are ready to be reviewed to get marked ready to merge labels Aug 24, 2026
Comment thread obspy/core/util/base.py
else:
if isinstance(filename, str) and \
Path(filename).stat().st_size == 0:
raise ValueError("File is empty: {}".format(filename))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In principle something like this is nice, but if we do it, I think we should have a proper function that goes through all the options a read input can have (str, BytesIO, ...) and checks for empty file.

@megies

megies commented Aug 26, 2026

Copy link
Copy Markdown
Member

I feel like let's wait for feedback. It seems a bit unclear what the actual use case for this was and if it helped make the error clearer.
I think it could be nice to have a better message for empty file in general, but then we should try to do it for all flavors the incoming read input can come in as.
That test change would need to be reverted too. All in all, maybe not quite ready yet and needs more discussion I feel?

@megies megies modified the milestones: 1.5.1, Future bugfix release Aug 26, 2026
@filefolder

Copy link
Copy Markdown
Contributor Author

TBH this PR can probably be flushed; it was mainly just to provide a clue for issues like #3549

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants