fix(cli): ao start --interactive crashes on flat local config#1793
fix(cli): ao start --interactive crashes on flat local config#1793i-trytoohard wants to merge 1 commit intomainfrom
Conversation
When `ao start --interactive` saves agent selections for a non-canonical config path, the else branch assumed `rawConfig.projects` exists. Flat local configs have no `projects:` key, causing a crash. Use the same readProjectBehaviorConfig/writeProjectBehaviorConfig helpers that the if-branch already uses, which handle both flat and wrapped shapes. Fixes #1791
Test Coverage Report
Uncovered lines
|
Greptile SummaryThis PR fixes a crash in
Confidence Score: 4/5Safe to merge — the crash fix is correct and non-destructive; the only remaining issue is cosmetic dead branching. The fix correctly eliminates the undefined-access crash by delegating to helpers that already handle all config shapes. The only leftover issue is that the if/else condition is now vacuous — both branches do exactly the same thing — which is a code quality concern but does not affect runtime correctness. packages/cli/src/commands/start.ts — the duplicate if/else block around lines 1528-1552 is worth collapsing.
|
| Filename | Overview |
|---|---|
| packages/cli/src/commands/start.ts | Crash fix for flat local config in --interactive mode; the if/else branches are now duplicate and can be collapsed to a single code path. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["ao start --interactive"] --> B["promptAgentSelection()"]
B --> C{agentOverride?}
C -- No --> G["runStartup()"]
C -- Yes --> D["readProjectBehaviorConfig(project.path)"]
D --> E["Set orchestrator.agent + worker.agent"]
E --> F["writeProjectBehaviorConfig(project.path, nextLocalConfig)"]
F --> G
Comments Outside Diff (1)
-
packages/cli/src/commands/start.ts, line 1528-1552 (link)After this fix, both branches of the
if/elseare byte-for-byte identical —isCanonicalGlobalConfigPathno longer produces any difference in behaviour. The entire conditional can be collapsed into a single code path, removing the dead branch.Prompt To Fix With AI
This is a comment left during a code review. Path: packages/cli/src/commands/start.ts Line: 1528-1552 Comment: After this fix, both branches of the `if`/`else` are byte-for-byte identical — `isCanonicalGlobalConfigPath` no longer produces any difference in behaviour. The entire conditional can be collapsed into a single code path, removing the dead branch. How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
packages/cli/src/commands/start.ts:1528-1552
After this fix, both branches of the `if`/`else` are byte-for-byte identical — `isCanonicalGlobalConfigPath` no longer produces any difference in behaviour. The entire conditional can be collapsed into a single code path, removing the dead branch.
```suggestion
const nextLocalConfig = readProjectBehaviorConfig(project.path);
nextLocalConfig.orchestrator = {
...(nextLocalConfig.orchestrator ?? {}),
agent: orchestratorAgent,
};
nextLocalConfig.worker = {
...(nextLocalConfig.worker ?? {}),
agent: workerAgent,
};
writeProjectBehaviorConfig(project.path, nextLocalConfig);
console.log(chalk.dim(` ✓ Saved to ${project.path}/agent-orchestrator.yaml\n`));
```
Reviews (1): Last reviewed commit: "fix(cli): use behavior config helpers fo..." | Re-trigger Greptile
Summary
ao start --interactivecrashes withCannot read properties of undefinedwhen the project uses a flat (non-wrapped) localagent-orchestrator.yaml.Root cause: The
elsebranch (non-canonical config path) reads raw YAML and assumesrawConfig.projects[projectId]exists. Flat configs have noprojects:key, so this isundefined[projectId]→ crash.Fix: Replace the raw YAML manipulation in the
elsebranch with the samereadProjectBehaviorConfig/writeProjectBehaviorConfighelpers that theifbranch already uses. These helpers correctly handle both flat and wrapped config shapes vialoadLocalProjectConfigDetailed.Fixes #1791
Test
agent-orchestrator.yaml(noprojects:key):ao start --interactiveCannot read properties of undefinedao startproceeds normallyAlso verify wrapped configs still work — the
readProjectBehaviorConfig/writeProjectBehaviorConfigpair handles both shapes transparently.