fix(frontend): identify the default branch by its flag, not the name "main" - #10129
Open
bilalabbad wants to merge 4 commits into
Open
fix(frontend): identify the default branch by its flag, not the name "main"#10129bilalabbad wants to merge 4 commits into
bilalabbad wants to merge 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 15 files
Shadow auto-approve: would not auto-approve because issues were found.
Re-trigger cubic
Contributor
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would not auto-approve. Auto-approval blocked by 4 unresolved issues from previous reviews.
Re-trigger cubic
…"main" The default branch name is set per deployment through INFRAHUB_INITIAL_DEFAULT_BRANCH, so comparing a branch name to the literal "main" is only correct on a deployment that kept the default. Branch sorting, the events branch filter and the conflict view now read the `is_default` flag, and `DEFAULT_BRANCH_NAME` is gone. Two of these were also reaching for the wrong branch entirely: a conflict in a proposed change is between its own destination branch and its source, not between "main" and the source; and the GraphQL endpoint builder no longer substitutes a branch name when the caller passes none. The server resolves an absent branch segment to its own default, whereas a guessed name that does not exist on the deployment is rejected outright — which left the branch list unable to load there. The unknown-branch toast says "the default branch" instead of naming main. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Every development stack, fixture and end-to-end suite runs with the default branch named main, so a name comparison behaves correctly in every environment a change is normally exercised in. Record where the name comes from, why the flag is the only reliable test, and which nearer source to reach for when the default branch is not actually the branch wanted. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
bilalabbad
force-pushed
the
bab-default-branch-by-flag
branch
from
August 5, 2026 10:54
723c25c to
afe5b47
Compare
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.
What changed and why
mainis the default default-branch name, not an invariant — a deployment sets it once throughINFRAHUB_INITIAL_DEFAULT_BRANCH, and the backend resolves it from configuration everywhere. The frontend compared branch names against the literal"main"in six places, so on a deployment that renamed its default branch each of them silently reported the wrong answer.Every comparison now reads the
is_defaultflag the API already returns, andDEFAULT_BRANCH_NAMEis deleted rather than left as a tempting constant.branches-to-select-options.tsname === "main"to the topis_defaultbranches-table.tsxname === "main"is_defaultevents/ui/filters/global-branch-filter.tsxname === "main"is_defaultdiff/ui/checks/data-conflict.tsx"main"shared/config/config.ts/graphql/${branch ?? "main"}branches/domain/model/branch.tsDEFAULT_BRANCH_NAME = "main"Two of these were reaching for the wrong branch, not just the wrong name
The conflict view. A data conflict is between a proposed change's destination branch and its source. Comparing against
"main"meant that for any proposed change targeting a non-default branch, bothfindcalls picked arbitrary sides — a display bug on every deployment, not only renamed ones.The GraphQL endpoint. Branch-agnostic callers — the branch list query, the create/delete branch mutations — were requesting
/graphql/main. Where no branch is namedmain,registry.get_branch(db, "main")raisesBranchNotFoundErrorand the endpoint returns 404 (backend/infrahub/graphql/app.py:135-138), so the branch list could not load at all. The server already serves/graphqlwithout a branch segment and resolves its own default (graphql/api/endpoints.py:25-26), so the client no longer guesses.User-facing copy
The unknown-branch toast said "you have been redirected to the main branch". It now says "the default branch". Both e2e suites assert that sentence verbatim, so
frontend/app/tests/e2e/branches/branch-selector.spec.tsandtests/e2e/branches/test_branch_selector.pyare updated in lockstep (the pytest case is renamedtest_unknown_branch_redirects_to_default).Documentation
A new
dev/knowledge/frontend/branches.mdrecords where the name comes from, why the flag is the only reliable test, and — the part that kept mattering here — which nearer source to reach for when the default branch is not actually the branch you want. It is registered infrontend/app/AGENTS.mdwith a load trigger, since a knowledge doc absent from that index never gets opened.Testing performed
Two GraphQL endpoint assertions in
client.test.tscomparedCONFIG.GRAPHQL_URL()against itself, so they passed regardless of the URL shape; they now assert literal URLs and genuinely pin the omitted branch segment.E2E not run — it needs a live stack. The assertions in both suites were updated together with the copy they check, and every
is_defaultchange is behaviour-identical when the default branch is namedmain, which is the configuration those suites boot. The only GraphQL route interceptions in either suite (login.spec.ts:154,test_login.py:159) match**/graphql/main**for theBuiltinTagoperation, which is branch-scoped and still resolves to/graphql/main.Note
No changelog fragment. CI only Vale-lints existing fragments (
ci.yml:1085) rather than requiring one, but this is user-visible on renamed deployments, so say the word and I will add afixedentry.🤖 Generated with Claude Code