Skip to content

Conversation

@andre-motta
Copy link
Contributor

@andre-motta andre-motta commented Nov 14, 2025

Add package name context to exception formatting to identify which
package failed during build errors. The package name is added by
FromagerLogRecord when messages are logged, and _format_exception
handles formatting chained exceptions with 'because' syntax.

Improve parallel build error handling to preserve package context
across thread boundaries using RuntimeError wrapper.

Tests added to test_external_commands.py verify error logging and
exception formatting include package names and handle chained exceptions.

Update e2e test pattern to match new log format that includes package names.

Closes: #845

@andre-motta andre-motta requested a review from a team as a code owner November 14, 2025 14:52
@mergify mergify bot added the ci label Nov 14, 2025
@andre-motta andre-motta force-pushed the fix-845-package-name-in-exception branch 3 times, most recently from 87b96b3 to dd1a51d Compare November 14, 2025 15:18
Copy link
Member

@LalatenduMohanty LalatenduMohanty left a comment

Choose a reason for hiding this comment

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

@andre-motta src/fromager/commands/download_sequence.py do not use RuntimeError() wrapper. Lets fix that as well

@LalatenduMohanty
Copy link
Member

@andre-motta Also 3 e2e tests are failing. PTAL

@LalatenduMohanty
Copy link
Member

Here is the fix to the e2e failures

diff --git a/src/fromager/__main__.py b/src/fromager/__main__.py
index 4c6428c..168de15 100644
--- a/src/fromager/__main__.py
+++ b/src/fromager/__main__.py
@@ -287,7 +287,7 @@ def invoke_main() -> None:
             err,
             exc_info=True,
         )  # log the full traceback details to the debug log file, if any
-        logger.error(f"ERROR: {_format_exception(err)}")
+        logger.error(_format_exception(err))
         if _DEBUG:
             raise
         sys.exit(1)

@andre-motta andre-motta force-pushed the fix-845-package-name-in-exception branch from dd1a51d to 06414b5 Compare November 14, 2025 22:25
@andre-motta
Copy link
Contributor Author

Addressed all feedback

@andre-motta andre-motta force-pushed the fix-845-package-name-in-exception branch from 06414b5 to d976e00 Compare November 14, 2025 22:29
Copy link
Member

@dhellmann dhellmann left a comment

Choose a reason for hiding this comment

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

It looks like the test job failures are due to the changes in the message format. That should be easy enough to fix. The change itself looks good.

@andre-motta andre-motta force-pushed the fix-845-package-name-in-exception branch from d976e00 to 3e59569 Compare November 15, 2025 14:05
@andre-motta
Copy link
Contributor Author

andre-motta commented Nov 15, 2025

It looks like the test job failures are due to the changes in the message format. That should be easy enough to fix. The change itself looks good.

Fixed the format, I also made some other changes as the fix I did to the raises actually mean I don't need the suggested changes in def _format_exception(exc) as they were causing duplication of the package name in the logs now that the exception context is correctly bubbled up to the logger class.

Heres an example of the duplication:

ERROR stevedore: stevedore: Unable to resolve requirement specifier stevedore==5.2.0 with constraint stevedore==4.0.0 because stevedore: found no match...

@andre-motta andre-motta force-pushed the fix-845-package-name-in-exception branch from 3e59569 to 36d97da Compare November 15, 2025 14:09
@andre-motta andre-motta changed the title Draft: include package name in exception messages fix: include package name in exception messages Nov 15, 2025
@LalatenduMohanty
Copy link
Member

LalatenduMohanty commented Nov 17, 2025

@andre-motta I am wondering if the current proposed fix is relatively fragile. Also I am also re-thinking about use of RuntimeError or should we take a different approach.

@tiran
Copy link
Collaborator

tiran commented Nov 17, 2025

A while ago I had the idea to wrap our hooks to have more detailed exceptions as well as separate exception classes for resolver, sdist, wheel build, and so on. Please take a look at the rough prototype https://github.com/tiran/fromager/pull/new/hook-exceptiongroup .

Copy link
Contributor

@rd4398 rd4398 left a comment

Choose a reason for hiding this comment

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

The changes look okay but looks like a rebase is needed.

@dhellmann
Copy link
Member

I think we could land this if it was rebased. Some of the other suggested improvements could come later.

@andre-motta
Copy link
Contributor Author

Rebased on main.

@LalatenduMohanty
Copy link
Member

I created issue to track the improvement suggestion by @tiran in #876

@LalatenduMohanty
Copy link
Member

@andre-motta There are two commits now, do we need two commits?

@andre-motta
Copy link
Contributor Author

Fixing it now @LalatenduMohanty

Add package name context to exception formatting to identify which
package failed during build errors. The package name is added by
FromagerLogRecord when messages are logged, and _format_exception
handles formatting chained exceptions with 'because' syntax.

Improve parallel build error handling to preserve package context
across thread boundaries using RuntimeError wrapper.

Tests added to test_external_commands.py verify error logging and
exception formatting include package names and handle chained exceptions.

Update e2e test pattern to match new log format that includes package names.

Closes: python-wheel-build#845
Signed-off-by: Andre Lustosa <[email protected]>
@andre-motta andre-motta force-pushed the fix-845-package-name-in-exception branch from f0a5467 to 2a5acda Compare December 8, 2025 19:38
@mergify mergify bot merged commit 32e9755 into python-wheel-build:main Dec 8, 2025
111 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Fromager no longer mentions the package name near the exception

5 participants