dabla opened a new pull request, #73601:
URL: https://github.com/apache/airflow/pull/73601

   Follow-up to #72688, which started evicting the cached 
`KiotaRequestAdapterHook` request adapter when Microsoft Graph answers `401 
Unauthorized`.
   
   Power BI reports an expired access token differently: `403 Forbidden` with 
error code `TokenExpired` ([documented 
here](https://learn.microsoft.com/en-us/power-bi/developer/embedded/troubleshoot-rest-api)).
 With a Power BI connection on the `msgraph` connection type, the response 
handler turned that into a plain `AirflowException`, so nothing evicted the 
cached adapter. The adapter kept its credential and the stale token, and every 
retry of a deferred sensor such as a workspace `scanStatus` check replayed the 
same expired token until the triggerer process was restarted:
   
   ```
   [2026-09-22T12:59:12.978705Z] INFO - Executing url 
'myorg/admin/workspaces/scanStatus/bdd66c1f-...' as 'Method.GET'
   [2026-09-22T12:59:12.979349Z] INFO - ClientSecretCredential.get_token 
succeeded
   [2026-09-22T12:59:13.148507Z] ERROR - An error occurred: {'error': {'code': 
'TokenExpired', 'message': 'Access token has expired, resubmit with a new 
access token'}}
   ```
   
   `DefaultResponseHandler` now raises `PermissionError` for `403` as it does 
for `401`, so `send_request` closes and evicts the cached adapter and the next 
call builds a fresh credential and token.
   
   Tests: the `send_request` eviction test is parametrized over both status 
codes and a new response handler test covers a `403 TokenExpired` body. The new 
handler test fails against the previous implementation.
   
   Checks run locally: the msgraph hook, operator, sensor and trigger unit 
tests (145 passed, 1 xfailed) and `prek run --from-ref upstream/main --stage 
pre-commit` with `check-provider-yaml-valid` skipped (`provider.yaml` is 
untouched; that hook runs Breeze in Docker, which is not usable on my machine). 
The manual prek stage was not completed for the same reason.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Code (Fable 5.1)
   
   Generated-by: Claude Code (Fable 5.1) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to