Skip to content

fix: catch a default or base branch the repository doesn't have - #298

Merged
kalaspuff merged 3 commits into
mainfrom
fctl/386-issue-about-invalidly-specified-branch-n
Oct 28, 2026
Merged

kalaspuff merged 3 commits into
mainfrom
fctl/386-issue-about-invalidly-specified-branch-n

Conversation

@fctl-sh

@fctl-sh fctl-sh Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Summary

A project's default branch was only checked for being a valid branch name, and a session whose base branch the repository lacked started an empty branch, with only a warning in its log. Now both ends catch it:

  • Where it is set: the control plane asks GitHub through the App (one GraphQL query: does the branch exist, is the repository empty, what is its default branch) when a PATCH changes the default branch or the repository, or when a POST that links a repository names a branch. A branch the repository lacks is refused with a validation error on default_branch, such as "acme/web has no branch named mian: push it first, or choose one it has, like main". Settings → Project shows it under Default branch. An empty repository takes any branch. Saving other settings never asks GitHub, even though the web app sends the branch with every save, so an outage or a branch deleted since doesn't block unrelated changes.
  • When a session starts: fctl-agent fails a session whose base branch is missing from a repository with commits. The reason names the branch and says what to do: choose another default branch (Settings → Project, or fctl projects set --default-branch) and start a new session, or push the branch and resume this one. For fctl run --base it says to start a new session from a branch the repository has. The agent removes the clone it just made, because a resume runs in the same sandbox and would otherwise reuse a checkout that isn't on the session's branch. Empty repositories still start an orphan branch.

Verified with unit tests for GitHub's answers, the messages and the agent's preparation against real git repositories. I checked the GraphQL query's answers against real GitHub: an existing branch, a missing one, a prefix of a branch with a slash, an empty repository, a missing repository and a renamed one. End to end in cargo xtask dev, with projects linked to octocat/Hello-World and an empty public repository: a missing default branch and --base nope fail with their messages, --base master works, resuming a failed session clones afresh in the same sandbox, and the empty repository starts an orphan branch. The dev stack has no GitHub App, so the control plane's call to GitHub ran only in unit tests. cargo xtask check --quick passes.

Only a control plane release is needed for the refusal. The agent change reaches sessions as hosts update: agents one version behind keep starting empty branches.

Screenshots

At 98409f0. A session whose project's default branch (main) octocat/Hello-World doesn't have, light theme at 1440 px and dark at 390 px. The reason shows twice, as the error notice and on the Failed line, as every preparation failure does:

A failed session's page, light theme

A failed session's page, dark theme at a phone's width

Settings → Project after saving mian as the default branch, in both themes. The dev stack has no GitHub App to ask, so Playwright answered the PATCH with the error this control plane sends:

Settings → Project refusing a default branch, light theme

Settings → Project refusing a default branch, dark theme

Worth confirming

  • Decision: a default branch the repository lacks is refused, not accepted with a warning: the issue left this to a person. Someone setting up a branch they're about to push pushes it first. With the agent change, accepting it would only fail every session until the branch exists.
  • Decision: a POST with create_repo and a default_branch is refused, since GitHub makes the new repository with one branch, which becomes the default. No fctl client sends both, and the API docs didn't list the field there.
  • Decision: fctl run --base and schedules' base branches aren't checked when a session is created: such sessions fail as they start, with the reason above. Checking them would add a GitHub call to every session start that names a base.

Fixes #273

fctl session

fctl-sh Bot added 3 commits October 28, 2026 08:47
…thout a base

The control plane asks GitHub, through the App, whether the repository has
a project's default branch when it or the repository changes (or a link
names one), and refuses one it lacks; an empty repository takes any.
fctl-agent fails a session whose base branch is missing from a repository
with commits, saying how to fix it, instead of starting an empty branch,
and leaves no clone for a resume to reuse. Empty repositories still start
an orphan branch.

Refs #273
Also shortens the agent's failure: the session page shows the branch it
would have made.
…ranch

Settings → Project shows a field's error under its field, and has no
repository: a refusal on repo, as for a repository the workspace may no
longer use, would show nowhere when someone changes the default branch.
fctl-agent also fails with the missing branch's message when it can't
remove the clone.
@fctl-sh
fctl-sh Bot requested a review from kalaspuff as a code owner October 28, 2026 13:01
@kalaspuff
kalaspuff merged commit 865e9e9 into main Oct 28, 2026
10 checks passed
@kalaspuff
kalaspuff deleted the fctl/386-issue-about-invalidly-specified-branch-n branch October 28, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Sessions start on an empty branch when the project's default branch isn't in its repository

1 participant