Repository navigation
fix(init): keep the settings that validate when --force replaces an invalid config - #1510
Conversation
…nvalid config Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The PR description documents sufficient testing: a representative built-CLI run covers same-team preservation and different-team config relocation. No commands from the PR were executed. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
@pcbeingused333 Thanks for taking #1500 Part 3. With the built CLI, a same-team config with recallEnabled: "yes" now keeps coAuthorEnabled: false and autoCompactTokens, names recallEnabled as dropped, and no longer says it is another install's config. A config that records another team repo is still moved aside, and an ssh-form remote counts as the same team as the https URL. This works in both workspace and user scope. Two things still block approval. Both come from the same-team path still treating the file as unreadable after the salvage.
We compared against a control: the same fixture without the bad value, which #1458 already handles. A first init A --agent claude,codex --inherit-user-scope, then the config edit and a queued learning, then init A --force:
| control (valid config) | this PR (config with one bad value) | |
|---|---|---|
inheritUserScope |
true |
gone |
enabledAgents |
[claude, codex] |
gone |
disabledAgents |
[] |
gone |
pending-learnings/l1.md |
kept | moved to pending-learnings.unknown |
- [P1 blocking] Four settings are still lost.
inheritUserScope,enabledAgents,disabledAgentsandtoolRootsare read fromcarriedConfig, which stays null on this path (src/init.ts:1777-1786,:2419-2425,:2435).toolRootsis from the code, the other three are from the run. With--agent claude,enabledAgentsbecomes[claude]instead of the member's list. The issue expects these carried as for a readable config, and the CI review'sinheritUserScopenote is one case of this. - [P1 blocking] Queued learnings are set aside. The final save (
src/init.ts:2444) still passes no previous config, so the queue goes topending-learnings.unknownwith "the previous install's config … could not be read". Those learnings stop being published until the member moves them back by hand.
Using the salvaged config as carriedConfig, and as the previous config at the final save, whenever it records this team repo would fix both. The e2e test would catch them with enabledAgents and a queued learning in its fixture.
- [P3 nit]
salvageConfigFilecasts withas LocalConfigan object that may lackusername. That matters once the salvaged config reaches code that expects a full one. - [P3 nit] A nested setting such as
workflowsis dropped whole when one of its subfields is wrong.
tsc, lint and the 115 init unit tests pass. The new e2e file passes 2/2 here, also with a symlinked TMPDIR, and its first case fails on main. CI hasn't run on this PR yet. #1509 and #1512 merge cleanly with it.
…-team re-init Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
Thanks for the careful review and the control table. Both blockers are fixed in a18293c:
The e2e file has a new case with This reply and the code change were prepared by an AI agent (Claude) working for the PR author. |
|
No new findings in the specified diff.
Only the diff was read; no PR code was run, built, or installed. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
@pcbeingused333 Thanks, approving a18293c4.
- Settings carried. With the built CLI, a toolRoots entry added to the fixture, and three same-team cases (workspace without
--agent, workspace with--agent claude, user scope), the config afterinit --forcematches the control run with a valid config. That coversinheritUserScope,enabledAgents,disabledAgentsandtoolRoots. - Queued learnings.
l1.mdstays inpending-learnings/in all three cases and with an ssh-form remote, and your new e2e case fails on2d2888b3. A config that records another team repo is still moved aside. - Checks. On a merge with current main (with #1509 and #1512), build,
tsc, lint, the 118 init unit tests, and the e2e files for this PR and #1458 (7/7) pass. CI is green at this head.
The CI review reported no new findings, and we agree. We accept leaving a nested setting with one bad subfield as a separate change, as you suggested.
Optional:
- [P3 nit] The try/catch around the second
resolveInheritUserScopecall (src/init.ts:1884-1890) can't fire, since it gets the same inputs as the first call at:1786, which already passed.
…nvalid config (Tencent#1510) init --force over a config that fails validation but records this team repo no longer treats it as another install's. It keeps the config in place, carries every key that validates on its own, including inheritUserScope, enabledAgents, disabledAgents and toolRoots, keeps queued learnings, and names each dropped key in a warning. A config that records another team repo is moved aside as before. Refs Tencent#1500
Summary
Refs #1500 (Part 3)
init --forceover a workspace config that fails validation (for examplerecallEnabled: "yes") treated it as another install's config: it moved it toconfig.yaml.previous, even for the same team, and wrote a new config without any of the member's settings. #1458 kept the settings of a config that parses; this is the case it does not reach.initnow reads what such a file still holds. It takes the team repo the file records and every key that validates on its own. When the recorded team repo is the oneinitis setting up, the config is not moved aside, the keys that validate are carried into the new config as #1458 does for a readable one, and each key that does not validate is named in a warning, for examplerecallEnabled in …/config.yaml is "yes" (Expected boolean, received string), so it was dropped. A config that records another team repo is moved aside as before.This covers
teamai init <url>on a team repository. Single-repo mode and--httpinit are not changed.Type of Change
Test Plan
npx tsc --noEmitpassesnpm run lintpassesnpx vitest runpasses (ran the init unit tests, 115 passed, not the whole suite)New e2e test
init-invalid-config-1500.test.ts, run against the built CLI with local team repositories: withrecallEnabled: "yes"andcoAuthorEnabled: false,init <same team> --forcekeepscoAuthorEnabled: false, namesrecallEnabledas dropped, prints no "another install's config" message and leaves noconfig.yaml.previous. Withrepo.remotenaming another team, it still moves the config aside. The first case fails without the change and passes with it.Related Issues
Refs #1500 (Part 3 only; Parts 1 and 2 are separate changes)
Notes for Reviewers
salvageConfigFilereads the file as YAML and validates each top-level key on its own withLocalConfigSchema.shape[key].safeParse;repo.remoteis only used to decide whether the file belongs to this team repo. A file that is not a YAML mapping, or records no team repo, is handled exactly as before.npm run buildfirst), likeinit-keeps-member-settings-1458.test.ts.This change was made with Claude Code.
🤖 Generated with Claude Code