Skip to content

Commit 95afea8

Browse files
bchapuisclaude
andcommitted
Restore user-table plan lookup in ExecutionManager for manual/WebSocket execution
The ExecutionManager handles manual execution via WebSocket where a real userId is available. The user's plan in the users table may differ from what resolveUserPlan derives from org subscription status (e.g. trialing orgs with pro users), so the DB lookup is the correct fallback here. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6f88cda commit 95afea8

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

apps/api/src/services/execution-manager.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77

88
import type { BlobParameter } from "@dafthunk/runtime";
99
import type { WorkflowExecution, WorkflowState } from "@dafthunk/types";
10+
import { eq } from "drizzle-orm";
1011
import type { Bindings } from "../context";
1112
import { createDatabase } from "../db/index";
12-
import {
13-
getOrganization,
14-
getOrganizationBillingInfo,
15-
resolveUserPlan,
16-
} from "../db/queries";
13+
import { getOrganization, getOrganizationBillingInfo } from "../db/queries";
14+
import { users } from "../db/schema";
1715
import {
1816
WorkflowExecutor,
1917
type WorkflowExecutorParameters,
@@ -57,8 +55,16 @@ export class ExecutionManager {
5755
}
5856
const { computeCredits, subscriptionStatus, overageLimit } = billingInfo;
5957

60-
// Resolve user plan from org billing info if not provided
61-
const resolvedUserPlan = userPlan || resolveUserPlan(billingInfo);
58+
// Get user's plan if not provided (e.g., for WebSocket-based execution)
59+
let resolvedUserPlan = userPlan;
60+
if (!resolvedUserPlan) {
61+
const [user] = await db
62+
.select({ plan: users.plan })
63+
.from(users)
64+
.where(eq(users.id, userId))
65+
.limit(1);
66+
resolvedUserPlan = user?.plan;
67+
}
6268

6369
validateWorkflowForExecution(state);
6470

0 commit comments

Comments
 (0)