File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -389,6 +389,7 @@ export class DefaultQueueManager implements QueueManager {
389389 const [ error , workerGroup ] = await tryCatch (
390390 workerGroupService . getDefaultWorkerGroupForProject ( {
391391 projectId : environment . projectId ,
392+ environmentDefaultWorkerGroupId : environment . defaultWorkerGroupId ,
392393 regionOverride,
393394 } )
394395 ) ;
Original file line number Diff line number Diff line change @@ -33,6 +33,29 @@ export function defaultVisibilityFilter(
3333 return { hidden : false , workloadType : { not : "MICROVM" } } ;
3434}
3535
36+ /**
37+ * Canonical fallback chain for a run's default region:
38+ * environment default -> project default -> global default.
39+ * Both the trigger path and the regions UI must use this order so the
40+ * displayed default matches what actually runs.
41+ */
42+ export function resolveEffectiveDefaultWorkerGroupId ( {
43+ environmentDefaultWorkerGroupId,
44+ projectDefaultWorkerGroupId,
45+ globalDefaultWorkerGroupId,
46+ } : {
47+ environmentDefaultWorkerGroupId ?: string | null ;
48+ projectDefaultWorkerGroupId ?: string | null ;
49+ globalDefaultWorkerGroupId ?: string | null ;
50+ } ) : string | undefined {
51+ return (
52+ environmentDefaultWorkerGroupId ??
53+ projectDefaultWorkerGroupId ??
54+ globalDefaultWorkerGroupId ??
55+ undefined
56+ ) ;
57+ }
58+
3659/**
3760 * Whether a region is accessible given compute access.
3861 * MICROVM regions require compute access; all other types pass through.
Original file line number Diff line number Diff line change @@ -220,9 +220,11 @@ export class WorkerGroupService extends WithRunEngine {
220220
221221 async getDefaultWorkerGroupForProject ( {
222222 projectId,
223+ environmentDefaultWorkerGroupId,
223224 regionOverride,
224225 } : {
225226 projectId : string ;
227+ environmentDefaultWorkerGroupId ?: string | null ;
226228 regionOverride ?: string ;
227229 } ) : Promise < WorkerInstanceGroup | undefined > {
228230 const project = await this . _prisma . project . findFirst ( {
@@ -282,6 +284,18 @@ export class WorkerGroupService extends WithRunEngine {
282284 return workerGroup ;
283285 }
284286
287+ // Resolution order must match resolveEffectiveDefaultWorkerGroupId:
288+ // environment default -> project default -> global default.
289+ if ( environmentDefaultWorkerGroupId ) {
290+ const envWorkerGroup = await this . _prisma . workerInstanceGroup . findFirst ( {
291+ where : { id : environmentDefaultWorkerGroupId } ,
292+ } ) ;
293+
294+ if ( envWorkerGroup ) {
295+ return envWorkerGroup ;
296+ }
297+ }
298+
285299 if ( project . defaultWorkerGroup ) {
286300 return project . defaultWorkerGroup ;
287301 }
You can’t perform that action at this time.
0 commit comments