Skip to content

Fix: Prevent AttributeError crash in prek when run inside container#57497

Merged
jscheffl merged 13 commits intoapache:mainfrom
sanju1198:fix-prek-container-crash
Oct 31, 2025
Merged

Fix: Prevent AttributeError crash in prek when run inside container#57497
jscheffl merged 13 commits intoapache:mainfrom
sanju1198:fix-prek-container-crash

Conversation

@sanju1198
Copy link
Contributor

This PR fixes an AttributeError: 'NoneType' object has no attribute 'print' that occurs when running prek inside the Breeze shell.

The console object is None in a non-TTY environment, and this PR adds if console: checks to prevent the script from crashing when console.print() is called.

This fixes the bug I found in the #new-contributors Slack.

…e failing

Revert virtualenv connections/variables access and logging as tests are failing in https://github.com/apache/airflow/actions/runs/18896380254. The issue here is that it's a socket initialisation error that occurs when CommsDecoder tries to create a socket from stdin (file descriptor 0) in subprocess environments where stdin is not a socket.

This reverts commit fb8b590 (PR apache#57213) which allowed virtualenv code to access connections/variables and send logs via supervisor comms reinitialization.
@boring-cyborg
Copy link

boring-cyborg bot commented Oct 29, 2025

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@boring-cyborg boring-cyborg bot added area:dev-tools area:providers backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch provider:standard labels Oct 29, 2025
@uranusjr
Copy link
Member

You should still print something using built-in print instead of just ignoring those.

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

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

NICE! Thanks for the investigation and fix !

@potiuk
Copy link
Member

potiuk commented Oct 29, 2025

NICE! Thanks for the investigation and fix !

With the caveat that the comment from @uranusjr will be addressed. In this case indeed the problem is that ich is not importable, but print should work

Copy link
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

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

Cool! Thanks for the fix!

@jscheffl jscheffl merged commit 5002660 into apache:main Oct 31, 2025
53 checks passed
@boring-cyborg
Copy link

boring-cyborg bot commented Oct 31, 2025

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

github-actions bot pushed a commit that referenced this pull request Oct 31, 2025
… container (#57497)

* Revert virtualenv connections/variables access and logging as test are failing

Revert virtualenv connections/variables access and logging as tests are failing in https://github.com/apache/airflow/actions/runs/18896380254. The issue here is that it's a socket initialisation error that occurs when CommsDecoder tries to create a socket from stdin (file descriptor 0) in subprocess environments where stdin is not a socket.

This reverts commit fb8b590 (PR #57213) which allowed virtualenv code to access connections/variables and send logs via supervisor comms reinitialization.

* Address review: Use built-in print as fallback

---------
(cherry picked from commit 5002660)

Co-authored-by: Gurram Sai Ganesh <gurramsaiganesh93@gmail.com>
Co-authored-by: Ankit Chaurasia <8670962+sunank200@users.noreply.github.com>
@github-actions
Copy link

Backport successfully created: v3-1-test

Status Branch Result
v3-1-test PR Link

jscheffl pushed a commit that referenced this pull request Oct 31, 2025
… container (#57497) (#57649)

* Revert virtualenv connections/variables access and logging as test are failing

Revert virtualenv connections/variables access and logging as tests are failing in https://github.com/apache/airflow/actions/runs/18896380254. The issue here is that it's a socket initialisation error that occurs when CommsDecoder tries to create a socket from stdin (file descriptor 0) in subprocess environments where stdin is not a socket.

This reverts commit fb8b590 (PR #57213) which allowed virtualenv code to access connections/variables and send logs via supervisor comms reinitialization.

* Address review: Use built-in print as fallback

---------
(cherry picked from commit 5002660)

Co-authored-by: Gurram Sai Ganesh <gurramsaiganesh93@gmail.com>
Co-authored-by: Ankit Chaurasia <8670962+sunank200@users.noreply.github.com>
ephraimbuddy pushed a commit that referenced this pull request Nov 3, 2025
… container (#57497) (#57649)

* Revert virtualenv connections/variables access and logging as test are failing

Revert virtualenv connections/variables access and logging as tests are failing in https://github.com/apache/airflow/actions/runs/18896380254. The issue here is that it's a socket initialisation error that occurs when CommsDecoder tries to create a socket from stdin (file descriptor 0) in subprocess environments where stdin is not a socket.

This reverts commit fb8b590 (PR #57213) which allowed virtualenv code to access connections/variables and send logs via supervisor comms reinitialization.

* Address review: Use built-in print as fallback

---------
(cherry picked from commit 5002660)

Co-authored-by: Gurram Sai Ganesh <gurramsaiganesh93@gmail.com>
Co-authored-by: Ankit Chaurasia <8670962+sunank200@users.noreply.github.com>
ephraimbuddy pushed a commit that referenced this pull request Nov 4, 2025
… container (#57497) (#57649)

* Revert virtualenv connections/variables access and logging as test are failing

Revert virtualenv connections/variables access and logging as tests are failing in https://github.com/apache/airflow/actions/runs/18896380254. The issue here is that it's a socket initialisation error that occurs when CommsDecoder tries to create a socket from stdin (file descriptor 0) in subprocess environments where stdin is not a socket.

This reverts commit fb8b590 (PR #57213) which allowed virtualenv code to access connections/variables and send logs via supervisor comms reinitialization.

* Address review: Use built-in print as fallback

---------
(cherry picked from commit 5002660)

Co-authored-by: Gurram Sai Ganesh <gurramsaiganesh93@gmail.com>
Co-authored-by: Ankit Chaurasia <8670962+sunank200@users.noreply.github.com>
@sanju1198 sanju1198 deleted the fix-prek-container-crash branch November 13, 2025 04:28
Copilot AI pushed a commit to jason810496/airflow that referenced this pull request Dec 5, 2025
…pache#57497)

* Revert virtualenv connections/variables access and logging as test are failing

Revert virtualenv connections/variables access and logging as tests are failing in https://github.com/apache/airflow/actions/runs/18896380254. The issue here is that it's a socket initialisation error that occurs when CommsDecoder tries to create a socket from stdin (file descriptor 0) in subprocess environments where stdin is not a socket.

This reverts commit fb8b590 (PR apache#57213) which allowed virtualenv code to access connections/variables and send logs via supervisor comms reinitialization.

* Address review: Use built-in print as fallback

---------

Co-authored-by: Ankit Chaurasia <8670962+sunank200@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-tools area:providers backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch provider:standard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants