-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Fix PowerBIHook to expand relative REST API URLs #60704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
87a4b76 to
220f7cf
Compare
|
This is weird, as I would expect the host url defined in your PowerBI connection to be automatically prepended to the relative url. The PowerBIHook extends the KiotaRequestAdapterHook, thus I would expect to behave in the same way. Also, why did you fully replace the code in the hook and test, this makes it very difficult to review? Could you post an example DAG how it's used and connection example? |
|
As I already suspected, the PowerBIHook already hard-codes the host, so normally the relative url should be resolved correctly: |
The relative url is automatically concatenated with the host by the RequestAdapter's RequestInformation class. |
What I’m observing in practice (Airflow 3.x, async execution path) is that
This happens consistently when calling methods such as |
Ok now I understand why it isn't working, you'are using async code in the PythonOperator, this is not possible yet until Airflow 3.2 is released. @potiuk Here also a nice example where the async PythonOperator will be helpful for people wanting to interact directly with the hooks. I would advise you to use the PowerBIOperator for this, as this will handle the async code for you in deferred mode behind the scenes, or you have to write you method like this: From Airflow 3.2+ you'll be able to do this: This explains why you are encountering issues, this example won't work as the KiotaRequestAdapterHook and PowerBIHook are asynchronous hooks, just like the HttpAsyncHook. |
|
The issue is not related to URL handling in PowerBIHook. It occurs because PowerBIHook (and KiotaRequestAdapterHook) are asynchronous hooks, and they were being called from a synchronous PythonOperator, which is not supported until Airflow 3.2. |
After further investigation, this turns out not to be an issue in so I’m closing this PR. Thanks for the guidance. |
|
@suii2210 Thank you for sharing the example DAG and explanation as this helped out understanding the issue. |
This PR fixes an issue in
PowerBIHookwhere relative Power BI REST API paths (for example, myorg/groups) were passed directly to the async request adapter.In Apache Airflow 3.x, this resulted in the following error during execution:
Request URL is missing an http:// or https:// protocol
Root Cause
PowerBIHook.run()forwarded relative endpoints directly toKiotaRequestAdapterHook.run().The async request adapter requires a fully qualified URL, causing failures when standard Power BI endpoints were used.
Solution
Normalize Power BI REST API endpoints inside
PowerBIHook.run()Prepend the official Power BI REST API base URL for relative paths:
https://api.powerbi.com/v1.0/
Preserve absolute URLs without modification
Keep all existing Power BI operators unchanged
Testing
Added unit tests to verify relative Power BI URLs are expanded correctly
Added unit tests to ensure absolute URLs remain unchanged
Existing Power BI hook tests continue to pass
Backward Compatibility
No breaking changes introduced
Compatible with both sync and async execution paths
Related Issue
Fixes #60573