Skip to content

fix(readiness): fail closed when the MinerU model cache root is unreadable - #2161

Open
alphaliujin wants to merge 1 commit into
HKUDS:mainfrom
alphaliujin:fix/mineru-readiness-home
Open

alphaliujin wants to merge 1 commit into
HKUDS:mainfrom
alphaliujin:fix/mineru-readiness-home

Conversation

@alphaliujin

Copy link
Copy Markdown

Problem

On container deployments the backend runs as the unprivileged deeptutor user (supervisor user=deeptutor), but HOME is inherited from supervisord, which runs as root. mineru_models_ready() therefore probes /root/.cache/modelscope/hub/models, and calls .is_dir() outside its try/except:

PermissionError: [Errno 13] Permission denied: '/root/.cache/modelscope/hub/models'

build_settings_readiness() catches every exception and records the row as parser_probe_failed, so Settings → Document Parsing shows MinerU as misconfigured with no actionable cause — while MinerU parsing itself works.

Changes

  • mineru_models_ready(): resolve the cache roots inside the guarded block and treat an unreadable/absent home as “cannot confirm”, returning False (models_missing). This matches the function's documented fail-closed contract instead of letting a PermissionError escape.
  • build_settings_readiness(): log the probe exception with a traceback before recording parser_probe_failed, so future probe failures are diagnosable.
  • Dockerfile: create /home/deeptutor and set HOME="/home/deeptutor" for both supervisor programs. This is the root cause; the other two changes keep the failure mode safe for existing images and non-container installs.
  • Regression test covering an unreadable cache root (returns False) and a readable cache (returns True).

Verification

  • Reproduced on a 1.7.0 container: with HOME=/root, the probe raised PermissionError and the API reported parser.mineru misconfigured / parser_probe_failed.
  • With the patch applied, the same scenario returns False, and a populated cache still returns True (manual test in the 1.7.0 container, all other dependencies identical).
  • A container started with HOME=/home/deeptutor reports mineru_models_ready() == True, and parser.mineru readiness is enabled_verified.

The container backend runs as the unprivileged deeptutor user while
supervisor leaves HOME pointing at root's home. mineru_models_ready()
probed <HOME>/.cache/modelscope/hub/models outside its try/except, so
the PermissionError propagated into build_settings_readiness(), which
maps any exception to parser_probe_failed and shows no cause in the UI.

- mineru_models_ready(): treat an unreadable/absent cache root as
  "cannot confirm" and return False (models_missing) instead of raising.
- build_settings_readiness(): log the parser probe exception with a
  traceback before recording parser_probe_failed.
- Dockerfile: create /home/deeptutor and set HOME for the backend and
  frontend supervisor programs, so profile data resolves under the
  service user.
- Add a regression test for the unreadable-cache-root case.

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.

1 participant