fix: recover workspace publication failures

This commit is contained in:
2026-08-04 01:10:35 +02:00
parent f95a18ab0d
commit 2573d87a0e
5 changed files with 207 additions and 11 deletions
+14 -4
View File
@@ -36,6 +36,8 @@ export type PublishWorkspaceRequest =
export class WorkspaceConflictError extends WorkspaceRegistryError {
constructor(
readonly fields: string[],
readonly expected: { commit: string; blob?: string },
readonly actual: { commit: string; blob?: string },
readonly base?: CanonicalWorkspace,
readonly local?: CanonicalWorkspace,
readonly remote?: CanonicalWorkspace,
@@ -168,10 +170,10 @@ export class WorkspaceRegistry {
if (request.baseCommit !== status.head || (
request.action !== "create" && existing?.blob !== request.baseBlob
)) {
throw await this.conflictFor(request, existing, local);
throw await this.conflictFor(request, status.head!, existing, local);
}
if (request.action === "create" && existing) throw await this.conflictFor(request, existing, local);
if (request.action !== "create" && !existing) throw await this.conflictFor(request, existing, local);
if (request.action === "create" && existing) throw await this.conflictFor(request, status.head!, existing, local);
if (request.action !== "create" && !existing) throw await this.conflictFor(request, status.head!, existing, local);
const yamlPath = workspacePath(id);
const docPaths = this.documentationPaths(id);
@@ -205,6 +207,7 @@ export class WorkspaceRegistry {
private async conflictFor(
request: PublishWorkspaceRequest,
currentCommit: string,
existing: WorkspaceRevision | undefined,
local: CanonicalWorkspace | undefined,
): Promise<WorkspaceConflictError> {
@@ -215,7 +218,14 @@ export class WorkspaceRegistry {
const read = await this.read(id);
remote = isCanonicalWorkspace(read.workspace) ? read.workspace : undefined;
}
return new WorkspaceConflictError(this.changedFields(base, remote), base, local, remote);
return new WorkspaceConflictError(
this.changedFields(base, remote),
{ commit: request.baseCommit, ...(request.action === "create" ? {} : { blob: request.baseBlob }) },
{ commit: currentCommit, ...(existing ? { blob: existing.blob } : {}) },
base,
local,
remote,
);
}
private async readSnapshotCanonical(commit: string, id: string): Promise<CanonicalWorkspace | undefined> {