fix: MinerU local mode fails every document on a 4.x server that requires an API key (#32838)

A self-hosted MinerU 4.x server started with an API key rejected every document with a 401, even with the key filled in under Documents settings, because local mode never sent it. The key is now sent with the document requests to a 4.x server whenever one is set. Servers without a key are unaffected.

Fixes #32836
This commit is contained in:
Classic298 2026-10-21 19:26:37 +02:00 • committed by GitHub
parent 6367a3cc40
commit 3e0564d11a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -273,8 +273,12 @@ class MinerULoader:
"""
Send one request to the MinerU V1 API and raise an HTTPException on failure.
"""
# A 4.x server started with --api-key rejects every V1 request without it
headers = {'Authorization': f'Bearer {self.api_key}'} if self.api_key else None
try:
response = requests.request(method, f'{self.api_url}{path}', timeout=self.timeout, **kwargs)
response = requests.request(
method, f'{self.api_url}{path}', headers=headers, timeout=self.timeout, **kwargs
)
response.raise_for_status()
except requests.Timeout:
raise HTTPException(