{"record":{"id":"eafdace3e0b681a6","repo":"can1357/oh-my-pi","slug":"environment-must-be-docker-apple-container","errorCode":null,"errorMessage":"--environment must be docker|apple-container","messagePattern":"--environment must be docker\\|apple-container","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/metaharness/src/runner.ts","lineNumber":356,"sourceCode":"\t\t\t\tprocess.stdout.write(HELP);\n\t\t\t\tprocess.exit(0);\n\t\t\t\tbreak;\n\t\t\tcase \"-e\":\n\t\t\tcase \"--env\": {\n\t\t\t\tconst spec = take(arg);\n\t\t\t\tconst eq2 = spec.indexOf(\"=\");\n\t\t\t\tif (eq2 === -1) {\n\t\t\t\t\tconst hostVal = process.env[spec];\n\t\t\t\t\tif (hostVal !== undefined) cfg.env[spec] = hostVal;\n\t\t\t\t} else {\n\t\t\t\t\tcfg.env[spec.slice(0, eq2)] = spec.slice(eq2 + 1);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"--environment\": {\n\t\t\t\tconst v = take(arg);\n\t\t\t\tif (v !== \"docker\" && v !== \"apple-container\") {\n\t\t\t\t\tthrow new Error(\"--environment must be docker|apple-container\");\n\t\t\t\t}\n\t\t\t\tcfg.envType = v;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`unknown flag: ${arg} (see --help)`);\n\t\t}\n\t}\n\tif (cfg.models.length === 0) cfg.models = [\"anthropic/claude-sonnet-4-6\"];\n\tif (cfg.envType === \"apple-container\") {\n\t\tif (cfg.hostNetwork) throw new Error(\"--host-network is docker-only (compose overlay)\");\n\t\t// host.docker.internal doesn't exist on vmnet; containers reach the host at the bridge address.\n\t\tif (cfg.gatewayUrl === DOCKER_GATEWAY_URL) cfg.gatewayUrl = VMNET_GATEWAY_URL;\n\t}\n\treturn cfg;\n}\n\n// ─────────────────────────────────────────────────────────────────── resume","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/metaharness/src/runner.ts#L338-L374","documentation":"parseArgs validates --environment against the two supported harness execution environments: docker and apple-container (Docker Desktop vs Apple's container runtime/vmnet). Any other value is rejected because environment-specific setup (networking, gateway URLs, compose files) branches on exactly these two.","triggerScenarios":"`runner --environment podman`, `--environment container`, `--environment Docker` (capitalized), or an interpolated value from CI that says something like 'kubernetes'.","commonSituations":"Users on Linux assuming other container runtimes are supported; scripts ported from other harnesses using different environment names; case-sensitivity typos.","solutions":["Use exactly `docker` or `apple-container` (lowercase).","On macOS wanting Apple's container runtime use `--environment apple-container`; otherwise use `--environment docker`.","Check `runner --help` for the current accepted values.","If you need a new environment type, it requires a code change — the check is a hardcoded string comparison."],"exampleFix":"// before\nrunner --environment Docker\n// after\nrunner --environment docker","handlingStrategy":"validation","validationCode":"const ENV_TYPES = [\"docker\",\"apple-container\"];\nif (environment !== undefined && !ENV_TYPES.includes(environment)) {\n  throw new Error(`--environment must be docker|apple-container, got: ${environment}`);\n}","typeGuard":"function isEnvType(v: unknown): v is \"docker\"|\"apple-container\" {\n  return v === \"docker\" || v === \"apple-container\";\n}","tryCatchPattern":"try {\n  await runHarness({ environment });\n} catch (e) {\n  if (e instanceof Error && e.message.includes(\"--environment must be\")) {\n    console.error(`Unsupported environment '${environment}'. Use docker or apple-container.`);\n  } else throw e;\n}","preventionTips":["Centralize the environment choice in one CI variable with a whitelist check.","Remember values are lowercase and exact — no shorthand, no capitalization.","Map unsupported runtimes (podman, k8s) to docker-compatible config before invoking."],"tags":["cli","argument-validation","environment","container"],"backgroundTag":"invalid-cli-flag-value","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}