WeKnora icon indicating copy to clipboard operation
WeKnora copied to clipboard

[Bug]: MinerU protocol detection fails behind authenticating API gateways (missing Authorization header)

Open JSJ189 opened this issue 1 month ago • 0 comments

Affected Component

Backend Service & API

Bug Description

In PR #3671 (feat(docparser): support MinerU 4.0 V1 API for self-hosted MinerU), detectMinerUProtocol was introduced to automatically distinguish between MinerU 4.0 V1 API and legacy MinerU <= 3.x by probing GET /v1/health.

However, detectMinerUProtocol does not accept or attach the configured Authorization: Bearer <API_KEY> header. When MinerU is deployed behind an authenticating API gateway, reverse proxy, or unified gateway (such as LiteLLM Proxy, Kong, APISIX, or Nginx with bearer auth), any request to /v1/health without an Authorization header is rejected with 401 Unauthorized (e.g. 401: Authentication Error, No api key passed in.).

Because detectMinerUProtocol does not pass the configured key and treats 401 as an unexpected status, it fails with: MinerU /v1/health status 401: ... and prevents both:

  1. "Test Connection" (PingMinerU) in parser engine settings, and
  2. Parsing documents with MinerU (MinerUReader.Read).

Even when the user has properly configured mineru_server_api_key, it is never passed to detectMinerUProtocol.

Steps to Reproduce

  1. Deploy MinerU 4.0 behind an authenticating API gateway (or enable Bearer token verification at the gateway/proxy).
  2. In WeKnora Settings -> Parser Engine -> MinerU (Self-hosted), configure:
    • Endpoint: http://<gateway-ip>:<port>/mineru/api
    • API Key: <valid-api-key>
  3. Click "Test Connection" (or try parsing any document).
  4. See error: MinerU 服务不可用: MinerU protocol detection: MinerU /v1/health status 401: ....

Expected Behavior

detectMinerUProtocol should attach Authorization: Bearer <apiKey> when an API key is configured, allowing health probing to succeed behind authenticating gateways.

Actual Behavior

detectMinerUProtocol makes an unauthenticated GET request, causing the gateway to reject it with 401 Unauthorized. Connection check and document parsing fail.

Environment

  • WeKnora Version: v0.8.3 / main
  • Deployment Method: Docker Compose
  • OS: Ubuntu 22.04 / Linux
  • MinerU Version: 4.0.12

Relevant Logs

MinerU 服务不可用: MinerU protocol detection: MinerU /v1/health status 401: {"error":{"message":"Authentication Error, No api key passed in.","type":"auth_error","param":null,"code":"401"}}

Confirmation

  • [x] I have searched existing issues and confirmed this is a new one

JSJ189 avatar Oct 19 '26 03:10 JSJ189