Skip to content

fix(project,jobs): stop webhook clobbering default_branch, target it on PR create - #162

Merged
xmiksay merged 2 commits into
masterfrom
161-project-default-branch-is-ignored-webhook-clobbers
Jul 10, 2026
Merged

xmiksay merged 2 commits into
masterfrom
161-project-default-branch-is-ignored-webhook-clobbers

Conversation

@xmiksay

@xmiksay xmiksay Bot commented Jul 10, 2026

Copy link
Copy Markdown

Summary

Fixes two leaks that both dragged the effective branch back to the provider repo's real default, defeating an operator's default_branch override:

  • Leak A — upsert_project re-synced default_branch from the webhook payload on every delivery, reverting an operator's update_remote edit on the next issue/comment/PR event. Fixed: the field now seeds from the payload only on first insert; it's operator-owned after that (same UI-gap contract as Project audit: webhook dedupe/spawn data-loss fixes + residual security/docs/UI cleanup #159's update_remote).
  • Leak B — gh pr create --fill / glab mr create --fill never set a target branch, so both CLIs defaulted the PR/MR base to the provider repo's own default branch. Fixed: Cli::create_pr now takes the project's default_branch and passes --base/--target-branch explicitly.
  • Minor — manual project creation stamped a blind "main" fallback when the operator left default_branch blank. Since there's no provider API call to look up a repo's real default, this now 400s and requires the field explicitly (frontend form updated to match — field is now required).

Test plan

  • cargo fmt --check, cargo clippy --all-targets -D warnings — clean
  • cargo test against both Postgres and SQLite backends — all green, including new coverage:
    • tests/project_default_branch.rs::reupsert_does_not_clobber_operator_default_branch_override — seeds a project, applies an operator override via update_remote, re-upserts with the original payload branch, asserts the override sticks
    • tests/project_default_branch.rs::reupsert_still_syncs_full_name_and_remote_url — confirms the other synced fields are untouched by the fix
    • src/jobs/prompt.rs::create_pr_targets_configured_default_branch — asserts --base/--target-branch carry the project's configured branch for both GitHub and GitLab, across the Issue and IssueComment prompt arms
  • npm run typecheck, npm run build, npm run test (vitest) — clean
  • docs/architecture.md updated to describe insert-only default_branch seeding and the explicit PR/MR target

Closes #161

xmiksay added 2 commits July 10, 2026 11:43
…on PR create

What: `upsert_project` no longer re-syncs `default_branch` from the webhook
payload on an existing project — only on first insert. `Cli::create_pr` now
takes the project's default branch and passes it explicitly
(`--base`/`--target-branch`) to `gh pr create`/`glab mr create`. Manual
project creation now requires `default_branch` instead of guessing "main".

Why: the operator's `update_remote` override (#159) was reverted by the very
next webhook delivery, since every event re-upserted the project with the
provider payload's own live default branch. Independently, PRs/MRs opened by
the agent always targeted the provider repo's real default (no --base/
--target-branch was ever passed), so work never landed on a configured
integration branch even before the override was reverted (#161).

How: made default_branch operator-owned post-insert (mirrors update_remote's
existing UI-gap fix); threaded default_branch into the PR/MR create command;
replaced the "main" fallback in manual project creation with a required-field
400, since there's no provider call to look up a repo's real default. Updated
docs/architecture.md and frontend types/validation to match.
What: remove the unneeded `review_body: _,` field pattern in the FixReview
event_id match arm — `..` already covers it.

Why: CI's clippy (pinned to a newer toolchain than ran locally) enforces
clippy::unneeded_wildcard_pattern as an error under -D warnings, failing the
lint gate on unrelated pre-existing code touched by this branch's build.
@xmiksay
xmiksay merged commit 678f9d6 into master Jul 10, 2026
2 checks passed
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.

Project default branch is ignored: webhook clobbers operator override + PRs target the remote default

1 participant