Skip to content

Display Docker build errors when builds fail (Fixes #35)#347

Closed
T-Rajeev30 wants to merge 4 commits intoosrf:mainfrom
T-Rajeev30:fix-build-errors
Closed

Display Docker build errors when builds fail (Fixes #35)#347
T-Rajeev30 wants to merge 4 commits intoosrf:mainfrom
T-Rajeev30:fix-build-errors

Conversation

@T-Rajeev30
Copy link
Contributor

Summary

Fixes #35 by displaying actual Docker build errors instead of the generic failure message when builds fail.

Notes

I previously opened a PR for this issue, but it grew beyond scope and included multiple changes, so I closed it and prepared this smaller PR focused only on surfacing Docker build errors.

@tfoote Could you please review this updated, minimal version?

@T-Rajeev30 T-Rajeev30 requested a review from tfoote as a code owner January 29, 2026 21:08
@T-Rajeev30
Copy link
Contributor Author

T-Rajeev30 commented Jan 30, 2026

Hi @tfoote gentle follow-up on this PR. A review at your convenience would help me proceed, as I’m planning to work on additional issues and would like to align with you before moving forward . Thanks for your time.

@T-Rajeev30
Copy link
Contributor Author

@tfoote can you please review it and can you please assign me some issue so that i can solve them

Copy link
Collaborator

@tfoote tfoote left a comment

Choose a reason for hiding this comment

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

I see the error coming out and that the error messages are shown.


^^^^^^
test/test_core.py Writing dockerfile to /tmp/tmp0r2m3yyt/Dockerfile
vvvvvv

FROM ubuntu:bionic
USER root

^^^^^^
Building docker file with arguments:  {'path': '/tmp/tmp0r2m3yyt', 'rm': True, 'nocache': False, 'pull': False}
build > Step 1/2 : FROM ubuntu:bionic
build >  ---> f9a80a55f492
build > Step 2/2 : USER root
build >  ---> Using cache
build >  ---> c3f42b90a98d
build > Successfully built c3f42b90a98d
Writing dockerfile to /tmp/tmpzvky9i3i/Dockerfile
vvvvvv
# Preamble from extension [broken_snippet]


FROM ubuntu:bionic
USER root
# Snippet from extension [broken_snippet]
BAD KEYWORD for a dockerfile
# User Snippet from extension [broken_snippet]


^^^^^^
Building docker file with arguments:  {'path': '/tmp/tmpzvky9i3i', 'rm': True, 'nocache': False, 'pull': False}
Docker build failed
 400 Client Error for http+docker://localhost/v1.52/build?q=False&nocache=False&rm=True&forcerm=False&pull=False: Bad Request ("dockerfile parse error on line 7: unknown instruction: BAD (did you mean ADD?)")
.

But I'm not seeing the failed build outputs along with the error. As far as I can tell nothing is going through the stream output as you can see from the lack of the different console output prefixes in my overridden print.

# dig.output_callback = lambda output: print("OVERRIDE build > %s" % output)
self.assertIn('BAD KEYWORD', dig.dockerfile)
self.assertEqual(dig.build(), 1)
# TODO(tfoote) capture the console output by passing in a custom output_callback and assert we see the error there
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please make sure that the error message can be confirmed in the console output by overriding the output_callback.

# Add broken build which breaks
mock_cli_args = {'broken_snippet': True}
dig = DockerImageGenerator(active_extensions, mock_cli_args, 'ubuntu:bionic')
# dig.output_callback = lambda output: print("OVERRIDE build > %s" % output)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I quickly mocked overriding the output callback but it doesn't appear to be working.

@T-Rajeev30
Copy link
Contributor Author

@tfoote can i do all these changes by next 24 hrs ??

@tfoote
Copy link
Collaborator

tfoote commented Feb 6, 2026

For future reference the past iteration of this was #345

In fhe future please just iterate and evolve the PR instead of creating a new one so that the history is clear to future reviewers.

@tfoote
Copy link
Collaborator

tfoote commented Mar 18, 2026

This doesn't seem to resolve the issue and is out of date.

@tfoote tfoote closed this Mar 18, 2026
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.

display build errors

2 participants