Skip to content

Conversation

@andre-motta
Copy link

@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
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
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...

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 <alustosa@redhat.com>
@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
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

3 participants