Skip to content

fix: extend catch_unwind to cover lock_pypi_packages for proper panic handling#5324

Merged
baszalmstra merged 6 commits intoprefix-dev:mainfrom
nichmor:fix/catch-unwind-pypi-locking
Jan 20, 2026
Merged

fix: extend catch_unwind to cover lock_pypi_packages for proper panic handling#5324
baszalmstra merged 6 commits intoprefix-dev:mainfrom
nichmor:fix/catch-unwind-pypi-locking

Conversation

@nichmor
Copy link
Contributor

@nichmor nichmor commented Jan 19, 2026

fixes: #5315

Summary

  • Moves the lock_pypi_packages call inside the catch_unwind block to properly catch panics that occur during wheel metadata fetching
  • Moves last_initialization_error() method from LazyBuildDispatch to LazyBuildDispatchDependencies since LazyBuildDispatch is moved into the async block and can't be accessed after the catch_unwind

This fixes panics like:

thread 'main2' panicked at crates/pixi_core/src/lock_file/resolve/build_dispatch.rs:447:17
Error: × failed to solve the pypi requirements of environment 'myagv' for platform 'linux-aarch64'
  ╰─▶ build dispatch initialization failed: there is no compatible Python interpreter for 'osx-arm64'

Testing

Tested by cloning the repository from the issue, and instead of using vendored conda package

rpi-gpio = {path = "./vendor/rpi-gpio"}

I'm using the one from pypi

[feature.myagv.pypi-dependencies]
RPi-GPIO = "==0.7.1"

When trying to lock, it produces the right error:
image

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.

Tools: Claude

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added sufficient tests to cover my changes.
  • I have verified that changes that would impact the JSON schema have been made in schema/model.py.

… handling

Moves the lock_pypi_packages call inside the catch_unwind block to properly
catch panics that occur during wheel metadata fetching. Also moves the
last_initialization_error method to LazyBuildDispatchDependencies since the
LazyBuildDispatch is moved into the async block.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@nichmor nichmor marked this pull request as draft January 19, 2026 10:34
@nichmor nichmor marked this pull request as ready for review January 19, 2026 12:50
@wolfv
Copy link
Member

wolfv commented Jan 19, 2026

Looks good to me and I think the error message is much better! I'll let @tdejager have another look at the code.

@tdejager
Copy link
Contributor

Nice! Maybe it would be good to move the last error out of the dependencies structure altogether, as it does not really count as a dependency.

Comment on lines +251 to +252
pub fn last_initialization_error(&self) -> Option<&LazyBuildDispatchError> {
self.last_error.get()
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if it would be doable to pull this out, or we need to rename the struct ;)

@tdejager
Copy link
Contributor

Also make sure to fill out the AI disclosure fully :)

@tdejager
Copy link
Contributor

Actually, now that I look at the description, I'm unsure what actually changed in the output. Is the description correct, from the original issue it seems that the miette error was never printed?

@nichmor
Copy link
Contributor Author

nichmor commented Jan 20, 2026

Actually, now that I look at the description, I'm unsure what actually changed in the output. Is the description correct, from the original issue it seems that the miette error was never printed?

the error itself from locking was never printed and only panicked

@baszalmstra baszalmstra merged commit 055cce2 into prefix-dev:main Jan 20, 2026
88 of 109 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v0.63.1: thread 'main' panicked at crates/pixi/src/main.rs:49:10

4 participants