Skip to content

fix(import): report failed team repo pushes - #1543

Closed
huong8373tt-beep wants to merge 1 commit into
Tencent:mainfrom
huong8373tt-beep:fix/1539-import-push-failure
Closed

huong8373tt-beep wants to merge 1 commit into
Tencent:mainfrom
huong8373tt-beep:fix/1539-import-push-failure

Conversation

@huong8373tt-beep

Copy link
Copy Markdown
Contributor

Closes #1539

Summary

import --dir previously swallowed team-repo push failures and printed a false success message. The next pull/push could discard the local-only import.

This change makes autoPushTeamRepo propagate push failures. Import commands therefore exit non-zero and do not print Pushed to team knowledge repo unless the push succeeds.

Changes

  • Propagate non-detached push errors from the import push helper.
  • Keep detached-repository errors unchanged.
  • Add regressions for the git helper and import --dir command path.

Validation

  • Focused Vitest: 86 passed
  • npm run typecheck
  • npm run lint
  • npm run build
  • git diff --check

@github-actions

Copy link
Copy Markdown
  • [P1 blocking] Missing real-CLI verification record. src/utils/git.ts:716 changes runtime behavior by propagating push failures, but the PR’s Validation section lists only unit tests, type checking, linting, build, and diff checks. The Code Review Rules require an end-to-end / real-CLI verification record for runtime changes. Add one representative CLI run after building, demonstrating that a rejected push exits non-zero without printing Pushed to team knowledge repo.

No other confirmed findings in the scoped diff. No earlier findings were supplied.

@huong8373tt-beep

Copy link
Copy Markdown
Contributor Author

Added the requested real-CLI verification on the current built dist/index.js (commit 44145441).

I created an isolated workspace/team-repo fixture, installed a bare remote pre-receive hook that rejects pushes, then ran:

node dist/index.js import --dir <source> --skip-enrich

Observed CLI result:

CLI_IMPORT_EXIT_CODE=1
! refs/heads/main:refs/heads/main [remote rejected] (pre-receive hook declined)
error: failed to push some refs
VERIFICATION=PASS: rejected push exits non-zero and does not claim publication.

The captured output does not contain Pushed to team knowledge repo. The local extraction completed before the rejected publish, while the command surfaced the remote failure and returned non-zero as intended.

The prior focused tests/typecheck/lint/build/diff checks remain recorded in the PR description.

@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.

@huong8373tt-beep Thanks for the fix and the record. #1541 (opened earlier) fixes the same issue. We review both in full, the first one ready merges, and the other closes.

With the built CLI at 44145441 against main (f7e11fe4): when another member has pushed main first, main prints ⚠ [git] autoPush failed (non-blocking), then ✔ Pushed to team knowledge repo, and exits 0 with nothing on the remote. This branch exits 1 and prints neither. After teamai pull, rerunning the import publishes the docs. With a pre-receive hook refusing main, it exits 1 and shows [remote rejected] (pre-receive hook declined) and remote: main is protected. The success path is unchanged, and DetachedTeamRepoError still reaches callers (team-ref.test.ts:268). tsc, lint and the changed test files pass, and CI is green. What blocks approval:

  • [P2 non-blocking on its own; we hold approval for an important item in scope] A failed push prints raw git output with no teamai line and no next step. #1539 asks for the cause and the next step. In the moved-main case the member sees:

    ✖ To file:///…/a.git
    !	refs/heads/main:refs/heads/main	[rejected] (fetch first)
    Done
    Pushing to file:///…/a.git
    error: failed to push some refs to 'file:///…/a.git'
    hint: … use
    hint: 'git pull' before pushing again.
    

    Nothing says that publishing the import failed, and the only advice is git's git pull, for a clone the member never works in. #1538 already does what's needed for deep-enrich: a teamai line (Failed to publish … to the team repo:), then git's full message, then Run `teamai pull`, then rerun this command.. Here the advice should come only for a fetch first / non-fast-forward rejection. A protected main gets no fix from a pull. Showing git's reason, as this PR does, is the half #1541 lacks.

Non-blocking:

  • [P2 non-blocking] The local claude-rules import (src/import.ts:512) still prints ✔ Import complete before the push, so a failed push shows a success line followed by the error. Moving that line after autoPushTeamRepo fixes it. We found this in the code; that path is interactive.
  • [P3 nit] The @deprecated Use autoPushViaMR instead for import flows. tag is removed from autoPushTeamRepo. Unless that's intended, keep it.
  • [P3 nit] Your record is in a comment. Please move it into the body.
  • [P3 nit] The new import-dir.test.ts case also passes on main, because importCmd already exits 1 when autoPushTeamRepo rejects. Only the git.test.ts case against a real remote separates main from this branch.

We read the iWiki import (it now exits 1 without iWiki import complete) but didn't run it, since it needs the service. This PR conflicts with #1541 in src/utils/git.ts, and merges cleanly with #1534, #1538 and the other open PRs.

The CI review asked for a real-CLI record. It ran before your comment, and the run you posted matches ours for the protected-main case.

@SaulMoro

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

@huong8373tt-beep Thanks for this fix and for the record. #1541 fixed the same issue and was ready first, so it's merged (793e0351) and #1539 is closed. It keeps git's reason in the message, as you did here, and adds the teamai pull advice only when main moved. Closing this one as a duplicate, per how we handle two PRs for one issue.

The ✔ Import complete before the claude-rules push that we noted here is fixed in #1541 too.

@SaulMoro SaulMoro closed this Oct 29, 2026
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.

[bug] import --dir reports a publish that failed, and the next push drops the imported docs

3 participants