Skip to content

fix(cli): NSC_SCHEMA is the env-var form of --schema (#192) - #193

Merged
thomaschristory merged 1 commit into
mainfrom
fix/nsc-schema-env-override
Oct 23, 2026
Merged

thomaschristory merged 1 commit into
mainfrom
fix/nsc-schema-env-override

Conversation

@thomaschristory

Copy link
Copy Markdown
Owner

Fixes #192.

Before this change, NSC_SCHEMA was used only to set profile.schema_url, and only when the value was a URL. As a result:

  • a local path was silently ignored;
  • an unreachable URL quietly fell back to the cached or bundled schema.

The new resolve_schema_override(overrides, env) in nsc/cli/runtime.py returns --schema if set, otherwise NSC_SCHEMA. An empty value counts as unset. build_runtime_context passes the result to resolve_command_model as the schema override. NSC_SCHEMA now behaves exactly like --schema: it loads the path or URL directly, skips the TTL, cache and bundled fallbacks, and a load failure exits 3 with Error: cannot load schema from <source>: <reason> (#189).

$ NSC_SCHEMA=./missing.json nsc dcim sites list
Error: cannot load schema from ./missing.json: not found     # exit 3
$ NSC_SCHEMA=http://127.0.0.1:1/s.json nsc ls x
Error: cannot load schema from http://127.0.0.1:1/s.json: request failed (...)   # exit 3

Tests: the new tests/cli/test_schema_env_override.py covers:

  • a local path being used, checked via a schema-only dcim widgets resource;
  • a missing file exiting 3;
  • an unreachable URL exiting 3 with no bundled fallback;
  • --schema winning over NSC_SCHEMA;
  • an empty NSC_SCHEMA counting as unset.

Docs: docs/architecture/schema-loading.md, docs/architecture/overview.md, CHANGELOG.

https://claude.ai/code/session_01RD8NgCVtp3yYFd6NSZpbUb

NSC_SCHEMA only fed profile.schema_url, so a local path was ignored and
an unreachable URL silently fell back to the cached/bundled schema.
Resolve it alongside --schema (flag wins) and pass it as the schema
override, so it loads the path or URL directly and a failure exits 3.

Claude-Session: https://claude.ai/code/session_01RD8NgCVtp3yYFd6NSZpbUb
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.

NSC_SCHEMA does not behave like --schema (local path ignored, unreachable URL silently falls back)

1 participant