Skip to content

fix(pull): exit 1 when the team repo fetch fails in a pull a person ran - #1512

Merged
SaulMoro merged 1 commit into
Tencent:mainfrom
pcbeingused333:fix/pull-fetch-failure-exit-1
Oct 28, 2026
Merged

SaulMoro merged 1 commit into
Tencent:mainfrom
pcbeingused333:fix/pull-fetch-failure-exit-1

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Summary

teamai pull exits 1 when the team repo fetch fails and a person ran it. Until now it set exitCode = 1 only for a pinned ref or a detached-HEAD recovery, so ✖ Pull failed: … does not appear to be a git repository still exited 0 and scripts and CI carried on. Hook pulls keep their rule: the silent pull a session hook or git hook runs (--silent, or options.gitHook) still exits 0 and records the failure as before.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Test Plan

  • npx tsc --noEmit passes

  • npm run lint passes (0 warnings, 0 errors)

  • npx vitest run passes — see below

  • Added/updated tests for the change

  • New e2e src/__tests__/e2e/pull-fetch-failure-exit-1500.test.ts runs the built CLI (dist/index.js): with the team remote removed, teamai pull --force prints Pull failed and exits 1; teamai pull --silent --force and hook-dispatch post-merge --tool git still exit 0. It fails on main (exit 0) and passes with the change.

  • pull-team-ref-1183.test.ts: the two cases "keeps an attached unpinned {workspace,user} pull successful when its remote is unavailable" asserted exit 0, which is the behaviour this issue asks to change (A1); they now expect 1 and are renamed.

  • Also run and passing: source-cache-isolation-e2e, source-shared-destination-e2e, cli-error-exit, push-env.

  • Environment note: everything was run in a Docker node:22 container as root. Six tests in pull-team-ref-1183.test.ts (co-author policy / read-only directory cases) and several unit files (usage-tracking, workflow-*) fail there; the six in the 1183 file fail identically on main without this change. The unit failures were not compared one by one against main, so CI is the check for the full unit suite.

  • Real-CLI record (built CLI, isolated HOME, team remote redirected to a missing path through url.<path>.insteadOf), npm run build then npx vitest run --config vitest.e2e.config.ts src/__tests__/e2e/pull-fetch-failure-exit-1500.test.ts at the head commit:

    ✓ pull exit status when the team repo cannot be fetched (#1500) > exits 1 for a pull a person ran, with the same message
    ✓ pull exit status when the team repo cannot be fetched (#1500) > keeps exit 0 for the silent pull a hook runs, and for a git hook pull
    Test Files  1 passed (1)
         Tests  2 passed (2)
    

    The same file on main: exits 1 for a pull a person ran fails with expected +0 to be 1; the hook case passes. No separate manual transcript was recorded.

Related Issues

Refs #1500 (Part 1, A1 and A2). A3–A5 (import deep enrich, init --http) and Parts 2–3 are left for separate PRs.

Notes for Reviewers

  • "Started by a person" is options.interactive === true && !options.gitHook; the CLI sets interactive from !--silent. A script that runs teamai pull --silent therefore still exits 0, since --silent is documented as "for hooks" and is what the hooks run. Say if you would rather key this on something else.
  • No docs mention a failed pull exiting 0 (grepped docs/guide, skill-data, READMEs); CHANGELOG.md ### Changed has an entry.

This change was prepared with the help of an AI assistant (Claude); the code and tests were reviewed before submission.

pull set exitCode = 1 for a failed team fetch only with a pinned ref or on
DetachedRecoveryError, so scripts and CI saw exit 0 after '✖ Pull failed'.
A pull started without --silent (and not by a git hook) now exits 1; the
silent pulls that session and git hooks run keep exit 0 and keep recording
the failure.

Refs Tencent#1500

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown

No findings in the specified PR diff.

The PR description satisfies the testing requirement: it records npm run build followed by passing tests that invoke the real built CLI, covering exit 1 for a normal pull and exit 0 for silent and git-hook pulls. A separate manual transcript or full provider × agent matrix is not required.

Review was read-only; I did not run, build, or install PR code.

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was generated by AI during triage.

@pcbeingused333 Thanks, approving dfa535a2.

  • A person's pull. With the built CLI and the team remote gone, teamai pull, pull --force, a user-scope pull and --dry-run pull go from exit 0 on main to exit 1 here, each with the same ✖ [workspace|user] Pull failed: … line.
  • Hook pulls. pull --silent, hook-dispatch post-merge --tool git and hook-dispatch session-start --tool claude still exit 0, and doctor still reports Last git hook run failed: post-merge could not fetch the team repo.
  • Internal callers. Only the CLI action sets interactive, and every internal caller of pull() passes silent: true, so none of them changes behavior.
  • Tests. The new e2e test fails on main (expected +0 to be 1) and passes here, also with a symlinked TMPDIR. The two pull-team-ref-1183 cases flip to exit 1, which is what #1500's A1 asks for. On a merge with main (after the oxlint change in #1414), lint and tsc pass. CI is green at this head.

The CI review reported no findings and accepted the body's record of the built CLI. We agree. The CHANGELOG.md entry under ### Changed merges cleanly with #1509's.

@SaulMoro
SaulMoro merged commit 829d5f0 into Tencent:main Oct 28, 2026
18 checks passed
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
…uns (Tencent#1512)

teamai pull exits 1 when the team repo cannot be fetched, as it already did for a pinned ref, so scripts and CI stop on a failed pull. A pull a session hook or git hook runs (--silent) still exits 0 and records the failure as before.

Refs Tencent#1500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants