{"record":{"id":"612cc4a72b480b0b","repo":"gitbutlerapp/gitbutler","slug":"no-branch-selected","errorCode":null,"errorMessage":"No branch selected!","messagePattern":"No branch selected!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/desktop/src/components/commit/CommitView.svelte","lineNumber":97,"sourceCode":"\t\t}\n\t}\n\n\tconst parsedMessage = $derived(splitMessage(commit.message));\n\n\tfunction combineParts(title?: string, description?: string): string {\n\t\tif (!title) {\n\t\t\treturn \"\";\n\t\t}\n\t\tif (description) {\n\t\t\treturn `${title}\\n\\n${description}`;\n\t\t}\n\t\treturn title;\n\t}\n\n\tasync function saveCommitMessage(title: string, description: string) {\n\t\tconst commitMessage = combineParts(title, description);\n\t\tif (!branchName) {\n\t\t\tthrow new Error(\"No branch selected!\");\n\t\t}\n\t\tif (!commitMessage) {\n\t\t\tshowToast({ message: \"Commit message is required\", style: \"danger\" });\n\t\t\treturn;\n\t\t}\n\n\t\tconst newCommitId = await updateCommitMessage({\n\t\t\tprojectId,\n\t\t\tstackId,\n\t\t\tcommitId: commit.id,\n\t\t\tmessage: commitMessage,\n\t\t\tdryRun: false,\n\t\t});\n\n\t\tif (stackId) {\n\t\t\tuiState.lane(stackId).selection.set({ branchName, commitId: newCommitId, previewOpen: true });\n\t\t}\n\t\tsetMode(\"view\");","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/apps/desktop/src/components/commit/CommitView.svelte#L79-L115","documentation":"Thrown by saveCommitMessage() in the commit-message editor when the branchName for the commit being amended is falsy. The function needs branchName to address updateCommitMessage({projectId, stackId, commitId, message}); it is a precondition supplied by the surrounding UI state, not by the user input (a missing message gets a toast instead, 'Commit message is required').","triggerScenarios":"Saving an edited commit message after the branch the commit belonged to stopped being resolvable: branchName prop/state is undefined or empty because the stack was deleted, the branch was renamed/removed out-of-band, or the panel was opened before workspace data finished loading.","commonSituations":"Commit panel left open while the underlying virtual branch was deleted or merged elsewhere; project workspace not yet hydrated when the user hits save; a concurrent GitButler session rewrote the stack.","solutions":["Close and reopen the commit view after the branch list has refreshed, then retry the save.","Verify the stack still exists and still contains this commit (check the stack list in the UI or `but` CLI).","In code, early-return with a toast when !branchName instead of throwing, so the editor degrades gracefully.","Recompute branchName from the commit's owning stack when the editor mounts, and disable the save button until it resolves."],"exampleFix":"// before\nasync function saveCommitMessage(title: string, description: string) {\n  const commitMessage = combineParts(title, description);\n  if (!branchName) {\n    throw new Error(\"No branch selected!\");\n  }\n  // ...\n}\n\n// after\nasync function saveCommitMessage(title: string, description: string) {\n  const commitMessage = combineParts(title, description);\n  if (!branchName) {\n    showToast({ message: \"The branch for this commit is gone — reload the workspace\", style: \"danger\" });\n    return;\n  }\n  // ...\n}","handlingStrategy":"validation","validationCode":"if (!branchName) {\n  showToast({ message: \"Select a branch before saving the commit message\", style: \"danger\" });\n  return;\n}\nawait saveCommitMessage(title, description);","typeGuard":"function hasBranchName(b: string | null | undefined): b is string {\n  return typeof b === \"string\" && b.trim().length > 0;\n}","tryCatchPattern":"try {\n  await saveCommitMessage(title, description);\n} catch (e) {\n  if (e instanceof Error && e.message === \"No branch selected!\") {\n    showToast({ message: \"The branch is gone — reload the workspace\", style: \"danger\" });\n  } else {\n    throw e;\n  }\n}","preventionTips":["Disable the save button in the commit editor until branchName resolves to a non-empty string.","Re-derive branchName from the commit's owning stack every time the editor opens.","Invalidate open commit editors when their stack or branch is deleted."],"tags":["svelte","gitbutler","commit","ui-state","desktop"],"backgroundTag":"missing-required-state","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-23T13:39:53.451Z"}