Skip to content

Refresh Azure AD tokens after Foundry 404 responses - #214

Draft
Bala (0xba1a) with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-azure-ad-token-refresh
Draft

Bala (0xba1a) with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-azure-ad-token-refresh

Conversation

Copilot AI commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

An expired Azure AD token can cause Azure AI Foundry requests to fail with HTTP 404. Refresh the token and retry the failed request once when a token provider is configured.

  • Recovery: AnthropicApi invokes the token provider and retries on 404.
  • Scope: Other errors and requests without a token provider are not retried.
except FoundryError as error:
    if error.status_code != 404 or not token_provider:
        raise
    token_provider()
    response = client.messages.create(...)

Copilot AI linked an issue Nov 3, 2026 that may be closed by this pull request
Co-authored-by: 0xba1a <2942888+0xba1a@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix azure-ad token refresh by adding re-fetch on 404 error Refresh Azure AD tokens after Foundry 404 responses Nov 3, 2026
Copilot AI requested a review from Bala (0xba1a) November 3, 2026 10:40
@codecov-commenter

Codecov Comments Bot (codecov-commenter) commented Nov 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 77.52%. Comparing base (f690e72) to head (6a6f0e6).

Files with missing lines Patch % Lines
src/microbots/llm/anthropic_api.py 90.90% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #214      +/-   ##
==========================================
+ Coverage   77.48%   77.52%   +0.03%     
==========================================
  Files          47       47              
  Lines        3256     3266      +10     
==========================================
+ Hits         2523     2532       +9     
- Misses        733      734       +1     
Flag Coverage Δ
ghcp 33.43% <0.00%> (-0.11%) ⬇️
integration 42.06% <0.00%> (-0.13%) ⬇️
ollama_local 34.26% <0.00%> (-0.11%) ⬇️
slow-browser 18.30% <0.00%> (-0.06%) ⬇️
slow-other 39.40% <0.00%> (-0.65%) ⬇️
unit 75.16% <90.90%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/microbots/llm/anthropic_api.py 98.59% <90.90%> (-1.41%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FIX: Azure-Ad token refresh

3 participants