gitbutlerapp/gitbutler · error
No commits are available for integration.
Error message
No commits are available for integration.
What it means
Thrown by the module-level helper firstCommitId when given an empty CommitPickerOption array. Integration step drafts require at least one commit to pick as the integration target, so an empty list is unrecoverable at this point. Callers build integration drafts (default drafts, primary commit id, kind changes) from the commit options of a branch.
Solutions
- Check that the branch has at least one commit before opening the integration editor or building a draft.
- Handle empty commit lists in the editor UI by showing a disabled/empty state instead of constructing a draft.
- Investigate why commitOptions is empty if the branch should have commits (fetch/refresh failure).
Example fix
// before
const draft = createDefaultIntegrationStepDraft(commitOptions);
// after
if (commitOptions.length === 0) {
showEmptyIntegrationState();
return;
}
const draft = createDefaultIntegrationStepDraft(commitOptions); Defensive patterns
Strategy: validation
Validate before calling
if (commitOptions.length === 0) {
renderEmptyIntegrationState();
return;
}
const draft = createDefaultIntegrationStepDraft(commitOptions); Type guard
function hasCommits(opts: CommitPickerOption[]): opts is [CommitPickerOption, ...CommitPickerOption[]] {
return opts.length > 0;
} Try / catch
try {
const draft = createDefaultIntegrationStepDraft(commitOptions);
} catch {
showEmptyIntegrationState();
} Prevention
- Guard the integration editor against branches with zero commits
- Treat empty commit lists as a distinct UI state, not an error path
- Verify commit data actually loaded before constructing drafts
When it happens
Trigger: Calling firstCommitId (indirectly via createDefaultIntegrationStepDraft, primaryCommitId, or changeIntegrationStepDraftKind) with commitOptions === [] — i.e. the branch has no commits available for integration.
Common situations: Opening the branch integration editor on a branch with zero commits, an unborn/orphan branch, or commit data that failed to load and defaulted to an empty array.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- Ambiguous branch identifier
- Branch ' ' already exists
- Branch ' ' not found
- Branch ' ' not found when checking for conflicts
- Branch name ' ' collides with existing branch
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/632caa9a1b792f7b.
Report an issue: GitHub.
Appendix: source
Thrown at apps/desktop/src/lib/upstream/branchIntegrationEditor.ts:34
| {
id: string;
kind: "pick" | "merge";
commitId: string;
}
| {
id: string;
kind: "squash";
commitIds: string[];
message: string;
};
function createStepId() {
return crypto.randomUUID();
}
function firstCommitId(commitOptions: CommitPickerOption[]): string {
const first = commitOptions[0];
if (!first) throw new Error("No commits are available for integration.");
return first.id;
}
function secondCommitId(commitOptions: CommitPickerOption[], selectedCommitId: string): string {
const second = commitOptions.find((option) => option.id !== selectedCommitId);
return second?.id ?? selectedCommitId;
}
function isIntegrated(commit: Pick<IntegrationDivergenceCommit, "targetRelation">): boolean {
return commit.targetRelation.kind !== "notIntegrated";
}
export function buildCommitPickerOptions(
initialIntegration: InitialBranchIntegration,
): CommitPickerOption[] {
return [
...initialIntegration.divergence.localOnly
.filter((commit) => !isIntegrated(commit))View on GitHub (pinned to 58e5313667)