← Back to issue list

fix: don't crash if "snap" is a file

View original Github issue

Metadata

Project
snapcraft
Number
#5512
Type
pull request
State
merged
Author
edisile
Labels
—
Created
Updated
Closed

Current evaluation

PR #5512 (commit 02e267fb9) merged: snapcraft now raises ProjectDirectoryTypeError with a clear message when ./snap is a file instead of crashing, fixing issue #5167.

Resolution: closed resolved

Reason: The PR was merged after 2 approvals; its diff added NotADirectoryError handling in get_snap_project() that raises craft_application.errors.ProjectDirectoryTypeError, resolving issue #5167.

Evaluated by: mr-cal-bot

No scores available.

Issue body

- [x] Have you followed the [guidelines for contributing](https://github.com/canonical/snapcraft/blob/main/CONTRIBUTING.md)? - [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)? - [x] Have you successfully run `make lint`? - [x] Have you successfully run `make test`? (some tests are failing on my machine because arm64 is not supported, CI passed all tests) --- This PR solves https://github.com/canonical/snapcraft/issues/5167 It does so by raising a ProjectDirectoryTypeError when the "${PWD}/snap" path is occupied by a file rather than a directory. To improve UX it also adds an error message when attempting to launch any snapcraft command that accesses the "${PWD}/snap" path and its contents

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved PR #5512 (commit 02e267fb9) merged: snapcraft now raises ProjectDirectoryTypeError with a clear message when ./snap is a file instead of crashing, fixing issue #5167.
stealth/space-bunny-alpha — closed resolved Merged in #5512 (02e267fb9): raises ProjectDirectoryTypeError with a clear message when ./snap is a file, preventing a crash and resolving #5167.
qwen/qwen3.6-35b-a3b — — Merged fix preventing crashes when the snap directory is replaced by a file. The change raises a ProjectDirectoryTypeError with improved error messaging, resolving issue #5167. Approved by two reviewers and passed CI checks.
qwen3.6-35b-a3b-mtp-q6 — — Merged. Resolves issue #5167 by raising a ProjectDirectoryTypeError when the snap directory is replaced by a file, preventing crashes and improving error messaging.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: canonical/snapcraft#5167 (confidence 98%)

    The underlying bug report that this PR explicitly says it solves; issue is closed.

Related issues

Issue Project State Summary Similarity
#5167 Snapcraft raises an internal error if there is a file called `snap` snapcraft closed Fixed by merged PR #5512 (commit 02e267fb9): get_snap_project now catches NotADirectoryError and raises ProjectDirectoryTypeError instead of crashing when a file named 'snap' exists in the project directory.
83%
#1717413 snapcraft snap with an unexisting dir shows a traceback snapcraft (launchpad) closed Missing-directory handling was fixed to return a clear SnapcraftEnvironmentError instead of a traceback; Launchpad bug #1717413 is closed as Fixed.
72%
#4680 fix: show better error when project file is missing snapcraft closed Merged in canonical/snapcraft#4680, improving the error shown when a project file is missing; the maintainer confirmed the code remained necessary for documentation links.
71%