Skip to content

[#526] fix-autocommit-pr-failed#532

Draft
nrslib wants to merge 1 commit intomainfrom
takt/526/fix-autocommit-pr-failed
Draft

[#526] fix-autocommit-pr-failed#532
nrslib wants to merge 1 commit intomainfrom
takt/526/fix-autocommit-pr-failed

Conversation

@nrslib
Copy link
Owner

@nrslib nrslib commented Mar 18, 2026

Summary

概要

autoCommitAndPush が失敗した場合(例:git worktreeロックによる push エラー)、タスクが pr_failed ではなく completed としてマークされる。その結果、originへのpushもPR作成も行われないまま、ユーザーに何も通知されない。

原因

autoCommit.jsgit push <projectDir> HEAD が例外をスローすると、メソッドは { success: false } を返す。

postExecution.js では PR作成ブロックが commitResult.success && commitResult.commitHash で制御されているため、success: false の場合はスキップされる:

const commitResult = autoCommitAndPush(execCwd, task, projectCwd);

if (commitResult.success && commitResult.commitHash && branch && shouldCreatePr) {
    // origin への push と PR 作成 → success: false の場合はスキップ
}

return {}; // prFailed がセットされないまま返る

prFailed がセットされないため、taskExecution.jspersistPrFailedTaskResult ではなく persistTaskResultstatus: 'completed')を呼び出す。

再現シナリオ

  1. ホストマシンでブランチ feature-X を git worktree としてチェックアウト
  2. ホストと sandbox が同じ .git/ ディレクトリを共有している(例:Docker bind mount)
  3. sandbox 上で takt を実行し、feature-X ブランチを対象とするタスクを処理
  4. takt がクローンを作成してコミットを作成
  5. git push <projectDir> HEAD が失敗:refusing to update checked out branch
  6. タスクは completed としてマークされる — push なし、PR なし、エラー表示なし

影響

  • ユーザーには [INFO] Task "..." completed と表示されるが PR は作成されない
  • 依存タスク(例:step-2 を base とする step-3)のPR作成が、step-2 が origin に push されていないために失敗する
  • 失敗が完全にサイレント — pr_failed にならないため takt list からリトライもできない

期待される動作

auto-commit の push が失敗した場合、他の PR 作成失敗と同様に pr_failed としてマークされるべき。

修正案

autoCommit.js でコミット処理と push 処理を分離し、push 失敗時でも commitHash が返るようにする:

const commitHash = stageAndCommit(cloneCwd, commitMessage, { ... });
if (!commitHash) {
    return { success: true, message: 'No changes to commit' };
}

try {
    execFileSync('git', ['push', projectDir, 'HEAD'], { cwd: cloneCwd, stdio: 'pipe' });
} catch (localPushErr) {
    log.warn('ローカルpushに失敗。postExecution経由でorigin pushを試みます', {
        error: getErrorMessage(localPushErr)
    });
}

return { success: true, commitHash, message: `...` };

これにより postExecution.js が origin への push と PR 作成を試み、それらが失敗した場合に正しく pr_failed をセットできる。

バージョン

  • takt: 0.32.1

Execution Report

Piece takt-default completed successfully.

Closes #526

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.

auto-commitのpush失敗時にタスクが pr_failed ではなく completed になる

1 participant