{"record":{"id":"612cc4a72b480b0b","repo":"gitbutlerapp/gitbutler","slug":"no-branch-selected","errorCode":null,"errorMessage":"No branch selected!","messagePattern":"No branch selected!","errorType":"validation","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/58e5313667b857ef39a730e380af31816a7b1768/apps/desktop/src/components/commit/CommitView.svelte#L79-L115","documentation":"In CommitView.svelte, saveCommitMessage throws Error(\"No branch selected!\") when the derived `branchName` (from the currently selected stack/branch state) is undefined while saving an edited commit message. The component cannot determine which branch the commit belongs to, so updating via stackService.updateCommitMessage would be unsafe.","triggerScenarios":"Editing and saving a commit message while no branch is currently selected — e.g. selection state was cleared, the stack/branch was deleted or rebased mid-edit, or the component rendered outside a valid lane selection so selected.current?.branchName is undefined.","commonSituations":"User deletes/renames the branch while the commit-message editor is open; stale UI state after a background rebase or undo; selection reset by another exclusive action; component mounted with missing lane state.","solutions":["Re-select the stack/branch in the UI before editing the commit message","Close and reopen the commit message editor so it re-derives branchName from fresh selection state","Guard the edit entry point: disable the edit mode if branchName is undefined instead of throwing on save","Refresh project/stack state (rebase/undo may have invalidated the previous selection)"],"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// after\nasync function saveCommitMessage(title: string, description: string) {\n  const commitMessage = combineParts(title, description);\n  if (!branchName) {\n    showToast({ message: \"Select a branch before editing this commit\", style: \"danger\" });\n    setMode(\"view\");\n    return;\n  }","handlingStrategy":"type-guard","validationCode":"const branchName = selected.current?.branchName;\nif (!branchName) {\n  showToast({ message: 'Select a branch first', style: 'danger' });\n  return;\n}\nawait saveCommitMessage(title, description);","typeGuard":"function canEditCommit(state: { branchName?: string }): state is { branchName: string } {\n  return typeof state.branchName === 'string' && state.branchName.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: 'No branch selected — select a branch and retry', style: 'danger' });\n    setMode('view');\n  } else { throw e; }\n}","preventionTips":["Disable the edit-commit-message action unless branchName is defined","Re-derive selection state after rebase/undo/branch-delete operations","Subscribe to selection changes and cancel open editors when the branch disappears","Treat exclusiveAction state as the single source of truth for editability"],"tags":["svelte","ui-state","guard"],"backgroundTag":"missing-required-argument","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}