← Back to issue list

fix(Source): Raise SourceNotFound for missing path-like sources

View original Github issue

Metadata

Project
craft-parts
Number
#1776
Type
pull request
State
open
Author
Harsh23Kashyap
Labels
—
Created
Updated
Closed
—

Current evaluation

Narrow fix to raise SourceNotFound instead of InvalidSourceType for missing path-like sources, with tests and changelog. Approved by 2 reviewers, CI has pending checks and a few failures.

Suggested action: needs review

Reason: The PR has 2 approvals and 0 unresolved review comments, indicating it is ready for maintainer review. The change is narrow and well-tested, improving error messages for missing local paths. CI has some pending checks and a few failures (including a Conventional Commits title check), but the core logic is sound and approved.

Evaluated by: mr-cal-bot

Impact: 50 Quick Win: 26 Complexity: 15 Confidence: 80 Actionability: 60

Issue body

## What A source specification that looks like a local path but does not exist (for example `snap/local` when snapcraft runs from the wrong directory) used to raise `InvalidSourceType`, whose message "unable to determine source type of 'snap/local'" sends the reader looking for a source-type problem that does not exist. The real problem is that the path was not found. This raises the library's existing `SourceNotFound` instead, which reports the real problem ("Failed to pull source: 'snap/local' not found.") with an actionable resolution ("Make sure the source path is correct and accessible."). That is the same error `LocalSource.pull` already raises for a missing path, so the behavior is consistent across the library. Scope is deliberately narrow: - Only sources containing a `/` without a URI scheme (`://`) and whose path does not exist take the new branch. URLs like `https://canonical.com` and bare names like `snap` keep raising `InvalidSourceType`, and the existing `test_unknown_source_type_from_uri` expectations are unchanged. - Existing local directories still resolve to the `local` source type. - `ignore_errors=True` still returns `""`. Fixes canonical/snapcraft#6501. The same message improvement also covers the path in canonical/snapcraft#5721. ## Tests - New `test_missing_path_like_source_raises_source_not_found` and `test_missing_path_like_source_ignore_errors` in `tests/unit/sources/test_sources.py`. The first fails without this change (raised `InvalidSourceType`) and passes with it. - `pytest tests/unit/sources/` passes except `test_base.py` URL-download tests and one `test_snap_source.py` case, which fail identically on unmodified main in this environment (they need network/snap tooling), so they are not affected by this change. - Changelog entry added under the unreleased section as CONTRIBUTING.md asks. ## Notes The absolute-path detail the reporter suggested is not in this change: `SourceNotFound` is the library's existing error and I did not want to fork its message shape. Happy to extend it to name the resolved path if preferred.

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b
Impact: 50
Quick Win: 26
Complexity: 15
Confidence: 80
Actionability: 60
needs review Narrow fix to raise SourceNotFound instead of InvalidSourceType for missing path-like sources, with tests and changelog. Approved by 2 reviewers, CI has pending checks and a few failures.
minimax/minimax-m3.1-flash:free
Impact: 46
Quick Win: 21
Complexity: 32
Confidence: 89
Actionability: 68
needs review Adds narrow source detection so missing slash-containing, scheme-less paths raise SourceNotFound rather than InvalidSourceType, with unit tests and a changelog entry. Canonical CLA passes; maintainer review remains pending.

Update history

Date Change
updated
updated
updated
updated
updated
created

Related work

  • Related To: snapcraft#6501 (confidence 90%)

    PR explicitly fixes this snapcraft issue by raising SourceNotFound with actionable error messages.

  • Related To: snapcraft#5721 (confidence 85%)

    PR body notes the same message improvement covers the path in this issue.

Related issues

No related issues found above the similarity threshold.