Skip to content

Commit 3cfa9b3

Browse files
committed
refactor(run-store): extract the dedicated-schema forbidden-relation lists
Name the control-plane-only relation lists the dedicated-store select guard rejects, instead of repeating them inline across the batch finders.
1 parent 43d6e33 commit 3cfa9b3

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

internal-packages/run-store/src/PostgresRunStore.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,16 @@ export function wrapRunOpsClientForErrorNormalization<C extends RunOpsCapableCli
493493
* so `instanceof Prisma.PrismaClientKnownRequestError` works regardless of which
494494
* generated client backs the store.
495495
*/
496+
// Relations present on the full control-plane schema but ABSENT from the dedicated run-ops subset;
497+
// selecting one against the dedicated client throws an opaque Prisma error for NEW-resident data.
498+
const BATCH_TASK_RUN_CONTROL_PLANE_RELATIONS = ["runsBlocked", "waitpoints", "runtimeEnvironment"];
499+
const TASK_RUN_ATTEMPT_CONTROL_PLANE_RELATIONS = [
500+
"backgroundWorker",
501+
"backgroundWorkerTask",
502+
"runtimeEnvironment",
503+
"queue",
504+
];
505+
496506
export class PostgresRunStore implements RunStore {
497507
private readonly prisma: RunOpsCapableClient;
498508
private readonly readOnlyPrisma: RunOpsCapableClient;
@@ -2055,7 +2065,7 @@ export class PostgresRunStore implements RunStore {
20552065
): Promise<Prisma.TaskRunAttemptGetPayload<T> | null> {
20562066
const prisma = client ?? this.readOnlyPrisma;
20572067

2058-
const forbidden = ["backgroundWorker", "backgroundWorkerTask", "runtimeEnvironment", "queue"];
2068+
const forbidden = TASK_RUN_ATTEMPT_CONTROL_PLANE_RELATIONS;
20592069
this.#assertSubsetSelectable(
20602070
(args as { include?: Record<string, unknown> }).include,
20612071
forbidden,
@@ -2120,7 +2130,7 @@ export class PostgresRunStore implements RunStore {
21202130

21212131
this.#assertSubsetSelectable(
21222132
args?.include as Record<string, unknown> | undefined,
2123-
["runsBlocked", "waitpoints", "runtimeEnvironment"],
2133+
BATCH_TASK_RUN_CONTROL_PLANE_RELATIONS,
21242134
"findBatchTaskRunById"
21252135
);
21262136

@@ -2140,7 +2150,7 @@ export class PostgresRunStore implements RunStore {
21402150

21412151
this.#assertSubsetSelectable(
21422152
args?.include as Record<string, unknown> | undefined,
2143-
["runsBlocked", "waitpoints", "runtimeEnvironment"],
2153+
BATCH_TASK_RUN_CONTROL_PLANE_RELATIONS,
21442154
"findBatchTaskRunByFriendlyId"
21452155
);
21462156

@@ -2162,7 +2172,7 @@ export class PostgresRunStore implements RunStore {
21622172

21632173
this.#assertSubsetSelectable(
21642174
args?.include as Record<string, unknown> | undefined,
2165-
["runsBlocked", "waitpoints", "runtimeEnvironment"],
2175+
BATCH_TASK_RUN_CONTROL_PLANE_RELATIONS,
21662176
"findBatchTaskRunByIdempotencyKey"
21672177
);
21682178

0 commit comments

Comments
 (0)