Skip to content

Commit 5e4ea09

Browse files
committed
fix(runtime): answer the clone landing's 501 in its own catch, leaving the save catch unchanged
The durability-degradation guard reads the save catch as a seam around saveMetaItem and refused its new early return. The landing's 501 is thrown before any write, so it is now caught around resolveDefaultCloneLanding alone. Every other failure is rethrown to the save catch, which is back to its main-branch form. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgUpnvPnJ1hR74pUrVj
1 parent 3721556 commit 5e4ea09

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

‎packages/runtime/src/domains/permission-set-clone.ts‎

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -594,12 +594,23 @@ export async function handlePermissionSetCloneWrite(
594594
if (refused) return newSimilarTargetRefusalAnswer(deps, refused);
595595
landing = { packageId: target.package, created: false };
596596
} else {
597-
landing = await resolveDefaultCloneLanding(ql, protocol, source, async (base) => {
598-
// [cloud#3814 D1] Declared replicas on the Redis driver: creating
599-
// the pair here would register a package on this replica alone.
600-
const oneReplica = await multiReplicaPairCreationRefusal(deps, context, ql, base, `Cloning permission set '${source.name}'`);
601-
if (oneReplica) throw multiReplicaPackageChangeError(oneReplica);
602-
});
597+
try {
598+
landing = await resolveDefaultCloneLanding(ql, protocol, source, async (base) => {
599+
// [cloud#3814 D1] Declared replicas on the Redis driver: creating
600+
// the pair here would register a package on this replica alone.
601+
const oneReplica = await multiReplicaPairCreationRefusal(deps, context, ql, base, `Cloning permission set '${source.name}'`);
602+
if (oneReplica) throw multiReplicaPackageChangeError(oneReplica);
603+
});
604+
} catch (err: unknown) {
605+
// [#37811] The landing's 501 (no paired customization package can
606+
// be ensured, so nothing was written), in the request's language.
607+
// Every other failure goes on to the catch below, as before.
608+
const thrown = err as { statusCode?: unknown; messageKey?: unknown; params?: Record<string, unknown> } | null;
609+
if (thrown?.statusCode === 501 && thrown.messageKey === PAIR_UNSUPPORTED_KEY) {
610+
return catalogNotImplemented(deps, context, PAIR_UNSUPPORTED_KEY, thrown.params);
611+
}
612+
throw err;
613+
}
603614
}
604615

605616
// ── 7. the save ─────────────────────────────────────────────────────
@@ -660,12 +671,6 @@ export async function handlePermissionSetCloneWrite(
660671
}),
661672
};
662673
} catch (err: unknown) {
663-
// [#37811] The landing's 501 (no paired customization package can be
664-
// ensured), in the request's language.
665-
const thrown = err as { statusCode?: unknown; messageKey?: unknown; params?: Record<string, unknown> } | null;
666-
if (thrown?.statusCode === 501 && thrown.messageKey === PAIR_UNSUPPORTED_KEY) {
667-
return catalogNotImplemented(deps, context, PAIR_UNSUPPORTED_KEY, thrown.params);
668-
}
669674
// A validation failure keeps its 400; a save refusal keeps its own
670675
// status and code (a precondition conflict 409, a schema refusal 422).
671676
return { handled: true, response: deps.errorFromThrown(err, 500) };

0 commit comments

Comments
 (0)