Skip to content

Conversation

@ArthurKretzer
Copy link
Contributor

@ArthurKretzer ArthurKretzer commented Sep 10, 2025


closes: #55433

Summary

This PR fixes a bug in the WeaviateHook where the port specified in the Airflow connection is ignored for non-HTTPS configurations, causing the hook to always default to port 80.

The root cause is an operator precedence issue in the http_port assignment. This change corrects the logic by adding parentheses to ensure the ternary operator is evaluated correctly, thus respecting the user-configured port.

Proposed Change

The logic in airflow/providers/weaviate/hooks/weaviate.py is corrected as follows:

  • Before:

    http_port=conn.port or 443 if http_secure else 80,
  • After:

    http_port=conn.port or (443 if http_secure else 80),

Tests

  • Existing unit tests for the Weaviate provider were executed and continue to pass.
  • This change is a direct logical fix, and a new test case could be added to specifically cover custom ports on non-HTTPS connections to prevent future regressions.

Documentation

  • No documentation changes are required. This PR aligns the hook's behavior with the expected and documented functionality.

@boring-cyborg
Copy link

boring-cyborg bot commented Sep 10, 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

@ArthurKretzer ArthurKretzer force-pushed the fix/weaviate-hook-port-logic branch from 356259a to 37ef803 Compare September 10, 2025 16:54
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for the fix. wondering if it would be better to have one parameterized test case to specifically test for this port configuration. For example,

if port is not specified and http_secure is False, then 80
if port is not specified and http_secure is True, then 443
if port is set to 8000 and http_secure is False, then 8000
etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review. I think that it would, but I must admit that I am not that good with testing frameworks so I have not risked including it at the moment.

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:weaviate stale Stale PRs per the .github/workflows/stale.yml policy file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug in WeaviateHook: HTTP port logic ignores connection port for non-HTTPS connections

2 participants