Skip to content

fix(model-stores): guard missing env and strip export prefix in compose flag resolver - #5874

Closed
vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/model-store-compose-flags-env
Closed

vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/model-store-compose-flags-env

Conversation

@vaibhavsrv

Copy link
Copy Markdown
Contributor

Why this matters

In ods/scripts/model-store-compose-flags.py, resolve_flags() attempts to read root / '.env' directly to discover the active model store identifier via (root / '.env').read_text(encoding='utf-8'). When invoked on clean checkouts, during preflight checks, or in decoupled environments where model stores are registered but .env has not yet been generated, this throws an unhandled FileNotFoundError (exit code 2). Furthermore, key matching checked key.strip() == 'ODS_ACTIVE_MODEL_STORE', which fails to recognize lines defined with the standard shell export prefix (e.g. export ODS_ACTIVE_MODEL_STORE="fast-ssd"), causing the script to fall back to the default overlay and fail to mount the active model store.

This patch adds a guard ensuring (root / '.env').is_file() before reading, uses safe replacement decoding on read, and normalizes candidate keys by stripping leading export prefixes. Missing .env files safely default to the 'default' identifier without aborting execution.

Validation

  • Tested baseline reproduction: verified that an installation tree with registered model stores but without .env threw FileNotFoundError and returned exit code 2; verified that export ODS_ACTIVE_MODEL_STORE=ssd failed to attach data/.active-model-store.compose.json.
  • Post-fix behavior: verified that missing .env safely defaults to 'default' and mounts .model-stores.compose.json, while export ODS_ACTIVE_MODEL_STORE="ssd" resolves and attaches data/.active-model-store.compose.json.
  • Model store test suite: 7 passed. py_compile, pytest, and diff checks pass; new regression test_model_store_compose_flags_env.py wired into Linux CI.

Overlap check

Risk / AI disclosure

AI-assisted investigation, implementation and CLI regressions. This strengthens Compose overlay resolution for external model stores; runtime daemon behavior, docker execution, and catalog models are not altered. Independent human review and platform/runtime qualification remain gates. No running configuration, deployment or upstream merge changed.

Follow-up integration evidence

Composed with #5870 at 680c2437b8e64987d88ca65bffc8c7df469d6d2c without conflicts. Production and test diffs passed together; adjacent compose flags and model-store tests remain intact.
Backlog composition was local-only (production/test diffs, excluding workflow/Makefile wiring); it is not an upstream merge or independent human approval. Declared live-review gates remain open.

@Lightheartdevs

Copy link
Copy Markdown
Collaborator

Thanks for this contribution. public-beta was promoted into main on 2026-09-24 and no longer receives changes, so we're closing pull requests that target it. This isn't a judgment on the change itself. If it's still needed, please rebase onto main and open a focused PR. See #7253 for details and the contribution policy.

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.

2 participants