fix(org-import): aggregate defaults.RequiredEnv into preflight check (issue #232) #249

Closed
claude-ceo-assistant wants to merge 1 commits from fix/issue232-org-import-required-env-aggregation into main

1 Commits

Author SHA1 Message Date
core-qa e0178b04c6 fix(org-import): aggregate defaults.RequiredEnv into preflight check (issue #232)
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 14s
sop-tier-check / tier-check (pull_request) Failing after 10s
audit-force-merge / audit (pull_request) Has been skipped
When importing an org template via `dir` path, the Import handler read the
YAML and called collectOrgEnv — but Defaults.RequiredEnv (carrying the
runtime's own env requirements, e.g. ANTHROPIC_API_KEY for claude-code)
was not in tmpl.RequiredEnv, so collectOrgEnv silently skipped it.
The canvas preflight modal bypasses this by passing a fully-populated
tmpl via the `template` body field, so the bug only manifests in the
`dir` (template-on-disk) import path.

Fix:
- Add RequiredEnv / RecommendedEnv fields to OrgDefaults struct (same
  shape as OrgTemplate.RequiredEnv). Templates on disk declare
  defaults.required_env at the defaults level; the import handler now
  injects these into tmpl.RequiredEnv / tmpl.RecommendedEnv before
  calling collectOrgEnv, so the preflight sees the runtime's requirements.
- collectOrgEnv is unchanged — it already walks the tree correctly. The
  injection point is in Import, not collectOrgEnv, so the existing test
  coverage is preserved.
- 3 new regression tests prove: (1) defaults.RequiredEnv flows into
  the union, (2) duplicate key with explicit org-level RequiredEnv
  deduplicates correctly, (3) any-of groups from defaults survive.

Repro scenario fixed: importing molecule-dev (38 workspaces, runtime=claude-
code, no explicit org-level RequiredEnv) now correctly blocks on
ANTHROPIC_API_KEY and shows the MissingKeysModal instead of silently
creating 38 NOT CONFIGURED workspaces.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 07:01:28 +00:00