fix: harden invalidation registry governance

This commit is contained in:
DongHyeonka
2026-08-01 23:59:11 +09:00
parent 73a50426d6
commit 0eb23875cb
15 changed files with 906 additions and 147 deletions
+8 -2
View File
@@ -1,5 +1,6 @@
import { isCacheInvalidationTopic } from "./cache-invalidation.ts";
import {
defineQueryNamespaceIdentity,
queryNamespaceIdentityKey,
type QueryNamespaceIdentity,
} from "./query-keys.ts";
@@ -111,8 +112,13 @@ export function indexInvalidationRegistry(
const namespaces = new Map<string, QueryNamespaceIdentity>();
for (const namespace of registry.namespaces) {
let namespaceKey: string;
let namespaceSnapshot: QueryNamespaceIdentity;
try {
namespaceKey = queryNamespaceIdentityKey(namespace);
namespaceSnapshot = defineQueryNamespaceIdentity(
namespace.namespaceId,
namespace.namespaceVersion,
);
namespaceKey = queryNamespaceIdentityKey(namespaceSnapshot);
} catch (error) {
throw new TypeError("Invalidation registry namespace is invalid.", {
cause: error,
@@ -121,7 +127,7 @@ export function indexInvalidationRegistry(
if (namespaces.has(namespaceKey)) {
throw new TypeError(`Duplicate invalidation namespace: ${namespaceKey}`);
}
namespaces.set(namespaceKey, namespace);
namespaces.set(namespaceKey, namespaceSnapshot);
}
const namespacesForTopic = new Map<string, QueryNamespaceIdentity[]>();