Repository navigation
fix(runs): bind the project default repository for manual runs of project LOOPs - #1468
Open
Robert0622 wants to merge 1 commit into
Open
Robert0622 wants to merge 1 commit into
Robert0622 wants to merge 1 commit into
Conversation
…ject LOOPs POST /api/runs only attached the project's default repository when the workflow was a raw generic template. A generic template must be copied into the project before it can be edited, and that copy (like any project LOOP) then started from the designer's Run dialog without any code checkout, while requirement dispatch of the same LOOP did bind the repository. Bind the project default repository for every LOOP started inside a project, matching requirement dispatch. Co-Authored-By: Claude Code <noreply@anthropic.com>
crispinhu27
approved these changes
Nov 26, 2026
crispinhu27
left a comment
Collaborator
There was a problem hiding this comment.
Code Review(自动化 CR · 初审):APPROVE
- 审查版本:head
89468c40(base mainbe6918d7,merge-base 相同) - 审查范围:
internal/httpapi/runs.go中POST /api/runs绑定项目默认仓库的条件(从wf.Generic改成req.ProjectID != ""),以及新增的TestManualRunOfProjectLOOPBindsProjectDefaultRepository。对照了dispatch.go的需求派发回退逻辑、engine.StartWithRepositories和startWorkflowDefinitionSeeded、requireProjectWriter权限检查、共享定时任务(scheduledWorkflow)以及runs_startMCP 这个调用方。
实际验证(隔离环境,无 GitHub 凭据,合成数据)
- 真实部署对照:本地 MariaDB 加 head/base 两个服务实例,用本地 HTTP 上的合成 bare git 仓库作为项目
sweep的默认仓库,项目内建一个普通(非 generic)LOOP,然后POST /api/runs {"workflowId":…,"projectId":"sweep"}:- head:201,
repositories=[<默认仓库>]、repository.repositoryId/provider/baseBranch都已填好;native 沙箱的 script 节点 run 实际 clone 了仓库(git 服务端有upload-pack请求,工作区里有run-…/app/README.md)。 - base:201,
repositories=[]、repository为空,工作区里没有 checkout。PR 描述的问题能复现,修复也成立。
- head:201,
- 新测试在 head 上通过;把同一个测试文件放到 base 上失败(
must bind the project default repository: [])。 go vet ./internal/httpapi/通过。go test ./internal/httpapi/(跳过 Browser/Chromium)在 head 和 base 上的失败集合完全相同,都是 4 项,原因都是容器里 bwrap 无法创建用户命名空间(环境原因,和本 PR 无关)。- CI 16/16 通过(含 core、platform-required、e2e-required)。
结论
没有发现由本 PR 引入的阻塞问题。另外记一个行为变化,不阻塞:项目的默认仓库无效(不存在或不属于该项目)时,非 generic LOOP 的手动运行现在会返回 409 repository_required(以前会在没有仓库的情况下启动)。这和需求派发拒绝无效绑定仓库的做法一致,PR 描述里也写明了。
未验证的部分:没有跑接真实模型的 Agent 节点(没有模型供应商凭据),节点执行只用 script 节点验证到 checkout 这一步。以上不代表代码一定没有缺陷。
Collaborator
Author
Code Review + Unit Test: PASS ✅审查版本: head 代码审查变更范围: 核心改动分析:
无安全/逻辑问题。 单元测试(本地验证)
before/after 均符合预期,修复有效。 部署级集成实测由另一会话并行进行,以该结果为准。 |
Collaborator
Author
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.



Problem
POST /api/runs(the LOOP designer's Run dialog,web/app/runs.js:startRun) only binds the project's default repository when the workflow is a raw generic template (wf.Generic). A generic template has to be copied into a project before it can be edited (adoptGenericWorkflowsetsGeneric=false). That copy, like any other project LOOP, then starts without any repository checkout, even when the project has a default repository.Requirement dispatch (
POST /api/issues/:id/dispatch,dispatch.go) falls back to the project default repository for every LOOP, so the same LOOP behaves differently depending on which button starts it.Reproduction (v0.4.3, be6918d, real deployment)
sweep-1613with default repositorysweep-repo(a private GitHub repo).POST /api/workflows/issue-fix-production/clone→issue-fix-native(projectIdsweep-1613), then publish.POST /api/runs {"workflowId":"issue-fix-native","projectId":"sweep-1613","input":"..."}→ run
repositoryis{"repositoryId":"","provider":"","name":"","baseBranch":""},repositories: null. The agents run with no code.POST /api/issues/<id>/dispatch {"workflowId":"issue-fix-native"}on the same project→
repository.repositoryId = "sweep-repo", the repo is cloned, and the LOOP runs clarify → design → implement → review on the code.Fix
Bind the project default repository for any LOOP started within a project (
req.ProjectID != ""). This matches requirement dispatch. Generic templates behave as before, including the existingrepository_required409 when the default repository is invalid.Tests
TestManualRunOfProjectLOOPBindsProjectDefaultRepository: fails before (must bind the project default repository: []), passes after.go test ./internal/httpapi/→ok(skipping two Chromium browser tests that fail on unmodified main in this container because Chromium can't start).go vet ./internal/httpapi/clean.🤖 Generated with Claude Code