Skip to content

Fix LZMA invalid file checking in utils#17984

Merged
mhvk merged 2 commits intoastropy:mainfrom
kYwzor:fixlzma
Apr 9, 2025
Merged

Fix LZMA invalid file checking in utils#17984
mhvk merged 2 commits intoastropy:mainfrom
kYwzor:fixlzma

Conversation

@kYwzor
Copy link
Copy Markdown
Member

@kYwzor kYwzor commented Apr 7, 2025

Description

This pull request is to address an incorrect check for invalid LZMA files. Fixes #17983.

The incorrect check is caused by a combination of factors:

  1. Even though the test_local_data_obj_invalid test looks like it's testing for the ".xz" case, it actually isn't. This is because the invalid.dat.xz file wasn't being created by the bad_compressed function, so the ".xz" was never actually triggered.
  2. utils.data was capturing exceptions for OSError, EOFError; the correct exception for an invalid file is lzma.LZMAError.
  3. utils.data was only comparing 3 bytes for the signature/magic; the correct signature for LZMA is 6 bytes long.

@github-actions github-actions bot added the utils label Apr 7, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2025

Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for rebase and squash.
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

kYwzor added a commit to kYwzor/astropy that referenced this pull request Apr 8, 2025
@kYwzor
Copy link
Copy Markdown
Member Author

kYwzor commented Apr 8, 2025

Huh, pretty sure the failed checks are unrelated. Every test was passing (except Check PR milestone / milestone_checker) before I added the towncrier file and there's no way that's the source of these failures. What's the best way to trigger CI again?

@kYwzor kYwzor changed the title Fix LZMA invalid file checking Fix LZMA invalid file checking in utils Apr 8, 2025
@pllim pllim added the Bug label Apr 8, 2025
@pllim
Copy link
Copy Markdown
Member

pllim commented Apr 8, 2025

@kYwzor , please make sure you are not branched from some outdated code. Try rebase? I do not see these failures on main.

@dhomeier , looks like you wrote the original support in #3667 . Are you able to review?

Thanks, all!

@pllim pllim added this to the v7.1.0 milestone Apr 8, 2025
@kYwzor
Copy link
Copy Markdown
Member Author

kYwzor commented Apr 9, 2025

I've done a rebase and almost everything is passing now... but three checks failed because they couldn't checkout(???).

@pllim

This comment was marked as resolved.

@kYwzor
Copy link
Copy Markdown
Member Author

kYwzor commented Apr 9, 2025

All in the green now thanks @pllim!

Copy link
Copy Markdown
Contributor

@mhvk mhvk left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@mhvk mhvk merged commit 58a0cc6 into astropy:main Apr 9, 2025
28 checks passed
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.

Invalid LZMA files are not properly checked on utils.data

3 participants