fix(pixi-build-python): clarify missing pyproject error#5922
fix(pixi-build-python): clarify missing pyproject error#5922lawrence3699 wants to merge 1 commit intoprefix-dev:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves UX for pixi-build-python by surfacing a dedicated, actionable error when a project is missing pyproject.toml, instead of bubbling up a low-level file I/O error during metadata loading.
Changes:
- Added a
MissingPyProjectTomlMetadataErrorvariant with a clearer message and diagnostic help text. - Updated manifest loading to map
ErrorKind::NotFoundto the new dedicated error. - Added a regression test asserting both the error variant and message content when
pyproject.tomlis absent.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| PyProjectToml(#[from] toml::de::Error), | ||
| #[error("failed to parse version from pyproject.toml, {0}")] | ||
| ParseVersion(ParseVersionError), | ||
| #[error("`pixi-build-python` requires a `pyproject.toml` in {0}")] |
There was a problem hiding this comment.
Error message says "requires a pyproject.toml in {0}", but {0} is a full file path (…/pyproject.toml). Using "at {0}" (or changing {0} to be the directory) would read more clearly and avoid implying {0} is a directory.
| #[error("`pixi-build-python` requires a `pyproject.toml` in {0}")] | |
| #[error("`pixi-build-python` requires a `pyproject.toml` at {0}")] |
| ); | ||
| assert!( | ||
| message.contains(&expected_path.display().to_string()), | ||
| "error should mention the manifest root: {message}" |
There was a problem hiding this comment.
This assertion checks that the error message contains the expected file path (.../pyproject.toml), but the failure text says "mention the manifest root". Updating the assertion message to match what’s actually being checked will make test failures less confusing.
| "error should mention the manifest root: {message}" | |
| "error should mention the `pyproject.toml` path: {message}" |
|
Thanks this is a great ux improvement! |
|
Perhaps one improvement would be if we could surface this error earlier, I think we could surface this in the first few lines of recipe generation. Because now the error still includes that it could read a certain metadata like the homepage. But the backend cannot work without a pyproject. |
Closes #5871
When
pixi-build-pythonis used without apyproject.toml, metadata loading currently fails with a raw file-open error while reading package metadata.This changes the metadata provider to surface a dedicated error that states that
pixi-build-pythonrequires apyproject.tomland points at the missing path.Validation:
cargo fmt --all --checkcargo test -p pixi-build-python metadata::tests:: -- --nocapture