Skip to content

Conversation

@HsiuChuanHsu
Copy link
Contributor

Issue

url_from_endpoint() returns incorrect relative path without calling get_conn() first, due to flawed lazy initialization

Cause

Logic used if not self.base_url for initialization, but empty strings evaluate to False, triggering incorrect behavior

Solution:

  • Added _base_url_initialized boolean flag to track initialization
  • Updated _set_base_url() to set the flag
  • Modified url_from_endpoint() to use flag for lazy initialization check

Closes: #54112


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

- Add _base_url_initialized flag to track initialization state
- Implement lazy initialization in url_from_endpoint() method
- Fix issue where url_from_endpoint() returns incorrect URL when called independently
@HsiuChuanHsu HsiuChuanHsu force-pushed the bug/http-hook-url-from-endpoint-fix branch from 1b9ac42 to eb68093 Compare August 10, 2025 23:28
Copy link
Contributor

@fritz-astronomer fritz-astronomer left a comment

Choose a reason for hiding this comment

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

lgtm

@potiuk
Copy link
Member

potiuk commented Aug 19, 2025

Nice

@potiuk potiuk merged commit bd46aa1 into apache:main Aug 19, 2025
75 checks passed
@HsiuChuanHsu
Copy link
Contributor Author

Thanks for the review!

mangal-vairalkar pushed a commit to mangal-vairalkar/airflow that referenced this pull request Aug 30, 2025
…he#54202)

* fix(http): fix HttpHook.url_from_endpoint() without get_conn() call

- Add _base_url_initialized flag to track initialization state
- Implement lazy initialization in url_from_endpoint() method
- Fix issue where url_from_endpoint() returns incorrect URL when called independently

* Add modification on url_from_endpoint to make sure base_url is set
@HsiuChuanHsu HsiuChuanHsu deleted the bug/http-hook-url-from-endpoint-fix branch September 9, 2025 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HttpHook public method url_from_endpoint bug

3 participants