{"record":{"id":"60c1f5698ea06238","repo":"gitbutlerapp/gitbutler","slug":"failed-to-create-a-new-commit","errorCode":null,"errorMessage":"Failed to create a new commit","messagePattern":"Failed to create a new commit","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/desktop/src/lib/dragging/dropHandlers/stackDropHandler.ts","lineNumber":85,"sourceCode":"\t\treturn true;\n\t}\n\n\taccepts(data: unknown) {\n\t\treturn (\n\t\t\tthis.acceptsChangeDropData(data) ||\n\t\t\tthis.acceptsBranchDropData(data) ||\n\t\t\tthis.acceptsHunkDropData(data) ||\n\t\t\tthis.acceptsCommitDropData(data)\n\t\t);\n\t}\n\n\tasync ondropChangeData(data: ChangeDropData) {\n\t\tswitch (data.selectionId.type) {\n\t\t\tcase \"commit\": {\n\t\t\t\tconst { stack, outcome, branchName } = await this.macros.createNewStackAndCommit();\n\n\t\t\t\tif (!outcome.newCommit) {\n\t\t\t\t\tthrow new Error(\"Failed to create a new commit\");\n\t\t\t\t}\n\n\t\t\t\tconst sourceStackId = data.stackId;\n\t\t\t\tconst sourceCommitId = data.selectionId.commitId;\n\t\t\t\tif (sourceStackId) {\n\t\t\t\t\tconst diffSpec = changesToDiffSpec(await data.treeChanges());\n\t\t\t\t\tawait this.macros.moveChangesToNewCommit(\n\t\t\t\t\t\tstack.id,\n\t\t\t\t\t\toutcome.newCommit,\n\t\t\t\t\t\tsourceStackId,\n\t\t\t\t\t\tsourceCommitId,\n\t\t\t\t\t\tbranchName,\n\t\t\t\t\t\tdiffSpec,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t// Should not happen, but just in case\n\t\t\t\t\tthrow new Error(\"Change drop data must specify the source stackId\");\n\t\t\t\t}","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/apps/desktop/src/lib/dragging/dropHandlers/stackDropHandler.ts#L67-L103","documentation":"Thrown by StackDzHandler.ondropChangeData in stackDropHandler.ts after calling macros.createNewStackAndCommit() for a drop with selectionId.type === \"commit\": the macro reported no newCommit in its outcome, meaning the underlying stack/commit creation mutation did not produce the commit the drop needs as its destination.","triggerScenarios":"createNewStackAndCommit() returns outcome.newCommit === null/undefined — e.g. the backend stack creation or commit mutation failed silently, the workspace had no assignable changes, or the dryRun/apply path produced no commit while the caller assumed success.","commonSituations":"Repository in a state blocking commit creation (hooks failing, index lock, unresolved conflicts); backend service error swallowed by the macro returning an outcome without newCommit; racing mutations where the stack was rewritten between creation and commit.","solutions":["Check the backend logs / toast output from createNewStackAndCommit for the underlying mutation failure (hooks, lock file, conflicts)","Resolve any git-level blockers (index.lock, pre-commit hook failures, merge conflicts) and retry the drop","Inspect macros.createNewStackAndCommit to confirm it surfaces errors instead of returning an outcome without newCommit","Retry the operation after refreshing workspace/stack state"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await handler.ondropChangeData(data);\n} catch (e) {\n  if (e instanceof Error && e.message === 'Failed to create a new commit') {\n    toast.error('Could not create the destination commit; check hooks, conflicts and repository state, then retry');\n  } else throw e;\n}","preventionTips":["Ensure no index.lock, failing hooks, or unresolved conflicts before dropping","Check createNewStackAndCommit's outcome/errors before consuming newCommit","Retry after refreshing workspace state if the mutation raced","Monitor backend logs for the underlying stack-service failure"],"tags":["git","commit-creation","desktop-app","mutation-failure"],"backgroundTag":"git-command-failed","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"}