Skip to content

fix(azure): preserve Entra auth while polling OCR - #40437

Closed
yujonglee-berri wants to merge 2 commits into
litellm_internal_stagingfrom
litellm_fix_azure_di_entra_polling
Closed

yujonglee-berri wants to merge 2 commits into
litellm_internal_stagingfrom
litellm_fix_azure_di_entra_polling

Conversation

@yujonglee-berri

@yujonglee-berri yujonglee-berri commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

How it solves it:

  • Forward accepted request authentication to polling calls
  • Cover subscription-key and Entra header forwarding

User Flow

Before: a developer uses Entra authentication for document OCR and the accepted analysis fails while LiteLLM polls for its result

  1. They call litellm.ocr() with azure_ai/doc-intelligence/prebuilt-layout, an Entra token, and a document URL
  2. Azure accepts the analysis request with 202 Accepted
  3. LiteLLM polls without the bearer token and returns Unknown operation status: None

After: the same Entra-authenticated OCR call returns its completed document analysis

  1. They call litellm.ocr() with azure_ai/doc-intelligence/prebuilt-layout, an Entra token, and a document URL
  2. Azure accepts the analysis request with 202 Accepted
  3. LiteLLM forwards the bearer token while polling and returns the completed OCR response

Relevant issues

Regression from #32018

Linear ticket

Pre-Submission checklist

  • I have added meaningful tests
  • The handful of test files covering my change pass locally
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review

Screenshots / Proof of Fix

Before (096984b)

  1. Call litellm.ocr() against Azure Document Intelligence with an Azure CLI Entra bearer token and a public PDF
  2. The analysis request returns 202 Accepted, but polling fails with Unknown operation status: None

After (40a01e5)

  1. Run PYTHONPATH="$PWD" /Users/yujonglee/dev/litellm/.venv/bin/python -m pytest tests/test_litellm/llms/azure_ai/test_azure_document_intelligence_ocr_transformation.py -q
  2. Output: 34 passed in 0.24s
  3. Call litellm.ocr() against Azure Document Intelligence with the same Azure CLI Entra bearer token and public PDF
  4. Output: POST Azure Document Intelligence OCR via Entra: model=doc-intelligence/prebuilt-layout, pages=2

Type

🐛 Bug Fix

Caveats (if any)

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

@yujonglee-berri
yujonglee-berri requested a review from a team September 9, 2026 18:23
@codspeed

codspeed Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_fix_azure_di_entra_polling (40a01e5) with litellm_internal_staging (096984b)

Open in CodSpeed

@greptile-apps

greptile-apps Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR preserves Azure Document Intelligence request authentication when polling accepted OCR operations

  • Forwards either the subscription key or Entra authorization header to polling requests
  • Adds regression coverage for both authentication methods
  • Adds explicit parameter types requested by the previous review

Confidence Score: 5/5

The PR appears safe to merge, with the authentication regression covered and the previous typing requirement fully addressed

Polling now preserves either supported Azure authentication header without introducing new failures, and the manually resolved previous finding is fully fixed by explicit parameter annotations

Important Files Changed

Filename Overview
litellm/llms/azure_ai/ocr/document_intelligence/transformation.py Safely carries accepted-request authentication into SSRF-validated OCR polling requests
tests/test_litellm/llms/azure_ai/test_azure_document_intelligence_ocr_transformation.py Covers subscription-key and Entra polling authentication with strongly typed parameters

Reviews (2): Last reviewed commit: "test(azure): type OCR polling auth cases" | Re-trigger Greptile

@codecov

codecov Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@yujonglee-berri
yujonglee-berri enabled auto-merge (squash) September 9, 2026 18:29
@yujonglee-berri

Copy link
Copy Markdown
Contributor Author

@greptile-apps review

auto-merge was automatically disabled September 12, 2026 18:09

Pull request was closed

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.

1 participant