Repository navigation
fix(source): exit 1 when a source command refuses - #2041
Merged
Merged
Conversation
teamai source add, remove, browse and add-http printed an error and returned with exit status 0, so a script or CI job read the refusal as success. Route every refusal through a helper that also sets process.exitCode, as teamRepoEditable already does for a detached clone. Refs Tencent#2040
This was referenced Nov 25, 2026
|
No findings in the specified diff. The PR description documents failing-first regression tests and representative real-CLI runs showing exit status changing from 0 to 1. It also explains the Windows verify-world limitation and pre-existing lint failures; no missing-testing blocker applies. Review was read-only. I did not run, build, or install anything from the PR. |
jeff-r2026
approved these changes
Nov 26, 2026
jeff-r2026
left a comment
Collaborator
There was a problem hiding this comment.
Verified on latest main (fdc845e + this PR) in the 2026-11-26 audit round: typecheck, build, lint, targeted unit tests and e2e all pass. Squash-merging.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
teamai source add,teamai source remove,teamai source browseandteamai source add-httpprinted an error and returned with exit status 0 when they refused a change, so a script or CI job read the refusal as success. Every one of those refusals now goes through a localrefuse()helper that also setsprocess.exitCode = 1, which is the behaviourteamRepoEditablein the same file already had for a detached clone (and what #1731 and #1741 did forroles/projectsandremove).Fixes #2040.
Type of Change
Test Plan
Failing test first:
src/__tests__/source-refusal-exit-code.test.tsfails onmainwithexpected undefined to be 1in all five cases, and passes with the fix.The test covers a duplicate name, a duplicate repository, a missing source for
remove, a missing source forbrowse, and an emptyadd-httpendpoint.source.test.tsanddry-run-load-path.test.tsalso run here; their Windows failures (\vs/in manifest paths, andEBUSYon temp-dir cleanup) reproduce on unmodifiedmain, and neither file is inwindows-tests.ts.npm run lintdoes not pass on this Windows checkout: it reports the 26 pre-existingteamai(family-facts)errors from the Windows path bug described in #1889 (fixed by the open #1967), before the docs step, andcheck-docssees CRLF against LF fixtures (#1942). The changed files themselves are clean:Real CLI
npm run verify:worldrefuses on Windows:A world needs a POSIX shell; Windows is not supported. Say so in the PR instead.The record below uses the built CLI (npm run build) in a temporary HOME and project whose team repo declares one source, with no real tool home orTEAMAI_*variable in the environment.Built from
mainat11138d4:Built from this branch at
64391e2:npx tsc --noEmitpassesnpm run lintpasses — blocked on the two pre-existing Windows defects above; the changed files passoxlintand CI runs the full lint.npx vitest run src/__tests__/source-refusal-exit-code.test.ts)Related Issues
Fixes #2040. No other issue or open PR covered these exit codes (searched titles and bodies for
source add/source remove/exit, and for the two error strings).Notes for Reviewers
log.error(...)refusals changed.source remove's twolog.warnpaths that keep state for manual review still exit 0; they are deliberate "kept, review this" outcomes rather than a failed command, and changing them would widen this PR.source addwith an unreachable repository leaves the source clone it made in~/.teamai/sources/; this PR only reports the failure with exit 1, as before.