fix: Add protocol validation to KiotaRequestAdapterHook#61103
Merged
dabla merged 7 commits intoapache:mainfrom Jan 29, 2026
Merged
fix: Add protocol validation to KiotaRequestAdapterHook#61103dabla merged 7 commits intoapache:mainfrom
dabla merged 7 commits intoapache:mainfrom
Conversation
Fixes apache#61081 PowerBIDatasetRefreshOperator was failing with 'Request URL missing protocol' error when URLs were configured without https:// prefix. Changes: - Add _ensure_protocol() method to validate and fix URLs - Fix logic bug in get_host() (changed 'or' to proper tuple check) - Add safety fallback when connection.schema is None - Add comprehensive tests for protocol handling This ensures URLs always have proper protocol prefix while maintaining backward compatibility.
henry3260
reviewed
Jan 27, 2026
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/msgraph.py
Outdated
Show resolved
Hide resolved
dabla
reviewed
Jan 27, 2026
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/msgraph.py
Outdated
Show resolved
Hide resolved
dabla
reviewed
Jan 27, 2026
Contributor
dabla
left a comment
There was a problem hiding this comment.
Good catch, thanks for the PR, some small changes and we're good.
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/msgraph.py
Outdated
Show resolved
Hide resolved
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/msgraph.py
Outdated
Show resolved
Hide resolved
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/msgraph.py
Outdated
Show resolved
Hide resolved
- Remove redundant if host else None check in __init__ - Use _ensure_protocol in get_host to stay DRY - Ensure _ensure_protocol returns None for empty strings All tests passing.
Contributor
Author
|
All feedback addressed! Thanks @henry3260 , @dabla Changes made:
All 10 tests passing. Ready for review! |
henry3260
reviewed
Jan 27, 2026
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/msgraph.py
Outdated
Show resolved
Hide resolved
- Changed _ensure_protocol parameter to accept str | None - Changed get_host return type to str (never returns None) - Used cast() for type narrowing where needed
Contributor
Author
|
@henry3260, @dabla Thanks for the review! I've addressed your feedback:
All tests pass and mypy checks pass now. Ready for another look when you have time! |
Contributor
Author
|
Hi @dabla , |
dabla
approved these changes
Jan 29, 2026
morelgeorge
pushed a commit
to morelgeorge/airflow
that referenced
this pull request
Feb 1, 2026
* fix: Add protocol validation to KiotaRequestAdapterHook Fixes apache#61081 PowerBIDatasetRefreshOperator was failing with 'Request URL missing protocol' error when URLs were configured without https:// prefix. Changes: - Add _ensure_protocol() method to validate and fix URLs - Fix logic bug in get_host() (changed 'or' to proper tuple check) - Add safety fallback when connection.schema is None - Add comprehensive tests for protocol handling This ensures URLs always have proper protocol prefix while maintaining backward compatibility. * refactor: Address review feedback - Remove redundant if host else None check in __init__ - Use _ensure_protocol in get_host to stay DRY - Ensure _ensure_protocol returns None for empty strings All tests passing. * fix: Update _ensure_protocol return type to include None * fix: Update type hints to properly handle None values * fix: Update type hints to properly handle None values - Changed _ensure_protocol parameter to accept str | None - Changed get_host return type to str (never returns None) - Used cast() for type narrowing where needed * made the code DRY
shashbha14
pushed a commit
to shashbha14/airflow
that referenced
this pull request
Feb 2, 2026
* fix: Add protocol validation to KiotaRequestAdapterHook Fixes apache#61081 PowerBIDatasetRefreshOperator was failing with 'Request URL missing protocol' error when URLs were configured without https:// prefix. Changes: - Add _ensure_protocol() method to validate and fix URLs - Fix logic bug in get_host() (changed 'or' to proper tuple check) - Add safety fallback when connection.schema is None - Add comprehensive tests for protocol handling This ensures URLs always have proper protocol prefix while maintaining backward compatibility. * refactor: Address review feedback - Remove redundant if host else None check in __init__ - Use _ensure_protocol in get_host to stay DRY - Ensure _ensure_protocol returns None for empty strings All tests passing. * fix: Update _ensure_protocol return type to include None * fix: Update type hints to properly handle None values * fix: Update type hints to properly handle None values - Changed _ensure_protocol parameter to accept str | None - Changed get_host return type to str (never returns None) - Used cast() for type narrowing where needed * made the code DRY
jason810496
pushed a commit
to abhijeets25012-tech/airflow
that referenced
this pull request
Feb 3, 2026
* fix: Add protocol validation to KiotaRequestAdapterHook Fixes apache#61081 PowerBIDatasetRefreshOperator was failing with 'Request URL missing protocol' error when URLs were configured without https:// prefix. Changes: - Add _ensure_protocol() method to validate and fix URLs - Fix logic bug in get_host() (changed 'or' to proper tuple check) - Add safety fallback when connection.schema is None - Add comprehensive tests for protocol handling This ensures URLs always have proper protocol prefix while maintaining backward compatibility. * refactor: Address review feedback - Remove redundant if host else None check in __init__ - Use _ensure_protocol in get_host to stay DRY - Ensure _ensure_protocol returns None for empty strings All tests passing. * fix: Update _ensure_protocol return type to include None * fix: Update type hints to properly handle None values * fix: Update type hints to properly handle None values - Changed _ensure_protocol parameter to accept str | None - Changed get_host return type to str (never returns None) - Used cast() for type narrowing where needed * made the code DRY
jhgoebbert
pushed a commit
to jhgoebbert/airflow_Owen-CH-Leung
that referenced
this pull request
Feb 8, 2026
* fix: Add protocol validation to KiotaRequestAdapterHook Fixes apache#61081 PowerBIDatasetRefreshOperator was failing with 'Request URL missing protocol' error when URLs were configured without https:// prefix. Changes: - Add _ensure_protocol() method to validate and fix URLs - Fix logic bug in get_host() (changed 'or' to proper tuple check) - Add safety fallback when connection.schema is None - Add comprehensive tests for protocol handling This ensures URLs always have proper protocol prefix while maintaining backward compatibility. * refactor: Address review feedback - Remove redundant if host else None check in __init__ - Use _ensure_protocol in get_host to stay DRY - Ensure _ensure_protocol returns None for empty strings All tests passing. * fix: Update _ensure_protocol return type to include None * fix: Update type hints to properly handle None values * fix: Update type hints to properly handle None values - Changed _ensure_protocol parameter to accept str | None - Changed get_host return type to str (never returns None) - Used cast() for type narrowing where needed * made the code DRY
81 tasks
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes protocol validation bug in
KiotaRequestAdapterHookthat causedPowerBIDatasetRefreshOperatorto fail withhttpx.UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocolerror.Root Cause
The hook had two bugs introduced in PR #45006:
get_host()method (line 238): Usedorinstead of tuple check__init__setself.hostdirectly without ensuring protocol prefixChanges
_ensure_protocol()method to validate and add protocol prefix when missingget_host()- changedorto proper tuple check withstartswith(("http://", "https://"))schema or "https") whenconnection.schemais NoneTestKiotaRequestAdapterHookProtocolwith 10 test cases covering all protocol scenariosTesting
closes: #61081
Was generative AI tooling used to co-author this PR?
Generated-by: Claude (Anthropic) following the guidelines
AI Assistance Details:
TestKiotaRequestAdapterHookProtocolclass with 10 test cases)Checklist:
prek run --all-files)