Skip to content

Commit a77df3f

Browse files
committed
fix(webapp): address review feedback on env default region
- Scope RegionsPresenter env lookup to the resolved project (+ archivedAt: null) so a mismatched env id can't surface a default from another project. - Index RuntimeEnvironment.defaultWorkerGroupId via a separate CONCURRENTLY migration to keep FK checks off a seq scan.
1 parent 2e3f817 commit a77df3f

3 files changed

Lines changed: 5 additions & 1 deletion

File tree

apps/webapp/app/presenters/v3/RegionsPresenter.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class RegionsPresenter extends BasePresenter {
7474
const environment = environmentId
7575
? await this._replica.runtimeEnvironment.findFirst({
7676
select: { defaultWorkerGroupId: true },
77-
where: { id: environmentId },
77+
where: { id: environmentId, projectId: project.id, archivedAt: null },
7878
})
7979
: null;
8080

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- CreateIndex
2+
CREATE INDEX CONCURRENTLY IF NOT EXISTS "RuntimeEnvironment_defaultWorkerGroupId_idx"
3+
ON "public"."RuntimeEnvironment"("defaultWorkerGroupId");

internal-packages/database/prisma/schema.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ model RuntimeEnvironment {
401401
@@index([parentEnvironmentId])
402402
@@index([projectId])
403403
@@index([organizationId])
404+
@@index([defaultWorkerGroupId])
404405
}
405406

406407
/// Records of previously-valid API keys that are still accepted for authentication

0 commit comments

Comments
 (0)