refactor: decompose 287-line assembleAndValidateConfig into named helpers#4894
Conversation
- Extract `readEnvVarFromEnvFiles` to `src/parsers/env-parsers.ts` as a reusable exported helper (replaces the 29-line nested closure) - Extract 5 named post-assembly validation helpers within config-assembly.ts: - `validateInfrastructureOptions` – docker host URI, path prefix, chroot binaries path - `applyRateLimitConfig` – rate-limit config build + flag validation - `validateFeatureFlagCompatibility` – token steering flag + env-all/env-file logs - `validateHostAccessConfig` – host service ports, host ports, skip-pull, docker.internal warn - `validateApiProxyOptions` – API proxy validation, status logging, target warnings, CLI proxy - `validateCopilotModelOption` – COPILOT_MODEL resolution and model-id validation - `assembleAndValidateConfig` reduces from 287 lines to ~40 lines (orchestrator only) - All 39 existing tests continue to pass; TypeScript compiles cleanly
assembleAndValidateConfig into named helpers
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (3 files)
Coverage comparison generated by |
There was a problem hiding this comment.
Pull request overview
Refactors assembleAndValidateConfig by extracting env-file parsing and post-assembly validation logic into named helper functions, aiming to keep config assembly readable while preserving existing behavior.
Changes:
- Added a reusable
readEnvVarFromEnvFiles(envFile, key)export for env-file key lookup. - Extracted post-assembly validation/guard blocks into focused helper functions and simplified
assembleAndValidateConfiginto an orchestrator.
Show a summary per file
| File | Description |
|---|---|
| src/parsers/env-parsers.ts | Introduces exported env-file variable reader used by config validation. |
| src/commands/validators/config-assembly.ts | Decomposes post-assembly guard logic into helper functions and streamlines assembleAndValidateConfig. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 2
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
🔥 Smoke Test: PAT Auth — PASS
Overall: PASS — Auth mode: PAT (COPILOT_GITHUB_TOKEN) cc
|
Smoke Test Results: Copilot BYOK (Direct Mode) ✅Status: PASS
Mode: Direct BYOK (COPILOT_PROVIDER_API_KEY) → api-proxy sidecar → api.githubcopilot.com cc
|
🤖 Smoke Test Results — PASS
PR: refactor: decompose 287-line Overall: PASS
|
Chroot Version Comparison Results
Overall: ❌ Not all versions match — Python and Node.js versions differ between host and chroot environments.
|
|
✅ fix(workflow): use gpt-5.4-mini and raise max-ai-credits for copilot-token-usage-analyzer Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
|
|
|
Running in direct BYOK mode (AWF_AUTH_TYPE=github-oidc + AWF_AUTH_AZURE_* + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw) authenticated via Microsoft Entra Overall status: FAIL
|
Smoke Test: GitHub Actions Services Connectivity
Overall: FAIL — Service containers are not reachable via
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
assembleAndValidateConfigmixed three unrelated concerns in a single 287-line function: an env-file parsing utility, config assembly, and seven independent post-assembly validation guards.Changes
src/parsers/env-parsers.tsreadEnvVarFromEnvFiles(envFile, key)as a reusable module-level export, replacing the 29-line nested closure that was previously only accessible insideassembleAndValidateConfig.src/commands/validators/config-assembly.tsSeven inline guard blocks extracted into named helpers:
validateInfrastructureOptions--docker-hostURI, path prefix & chroot binaries pathapplyRateLimitConfigvalidateFeatureFlagCompatibility--env-all/--env-fileloggingvalidateHostAccessConfig--skip-pull/--build-local,host.docker.internalwarnvalidateApiProxyOptionsvalidateCopilotModelOptionCOPILOT_MODELfrom all sources and validates identifierassembleAndValidateConfigis now a ~40-line orchestrator:No behaviour changes; all 39 existing tests pass.