Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Joshenlim/fe 4174 project creation ignores selected us east 1 region (#49092)

Joshen Limbddb806b5733
diff --git a/apps/studio/components/interfaces/ProjectCreation/ProjectCreationForm.tsx b/apps/studio/components/interfaces/ProjectCreation/ProjectCreationForm.tsx
index 5e3ad93b6db..99f9cb7658e 100644
--- a/apps/studio/components/interfaces/ProjectCreation/ProjectCreationForm.tsx
+++ b/apps/studio/components/interfaces/ProjectCreation/ProjectCreationForm.tsx
@@ -443,13 +443,9 @@ export const ProjectCreationForm = ({
extractPostgresVersionDetails(postgresVersionSelection)
const { smartGroup = [], specific = [] } = availableRegionsData?.all ?? {}
- const selectedRegion =
- highAvailability && highAvailabilityRegionCode !== undefined
- ? specific.find((region) => region.code === highAvailabilityRegionCode)
- : smartRegionEnabled
- ? (smartGroup.find((x) => x.name === dbRegion) ??
- specific.find((x) => x.name === dbRegion))
- : undefined
+ const selectedRegion = smartRegionEnabled
+ ? (smartGroup.find((x) => x.name === dbRegion) ?? specific.find((x) => x.name === dbRegion))
+ : undefined
if (highAvailability && highAvailabilityRegionCode !== undefined && !selectedRegion) {
return toast.error(
diff --git a/apps/studio/tests/pages/new/[slug].test.tsx b/apps/studio/tests/pages/new/[slug].test.tsx
index 652b1f59c87..46b5ddc229d 100644
--- a/apps/studio/tests/pages/new/[slug].test.tsx
+++ b/apps/studio/tests/pages/new/[slug].test.tsx
@@ -792,6 +792,37 @@ describe('project creation wizard', () => {
expect(body.custom_supabase_internal_requests).toBeUndefined()
})
+ // Regression (FE-4174): in local dev, region choice isn't restricted to the fixed HA
+ // region (unlike staging), so a manual selection should be respected. onSubmit used to
+ // resolve the HA region purely from highAvailabilityRegionCode without that same
+ // exception, silently sending the fixed region regardless of what was displayed.
+ test('submits the manually selected region in local dev instead of the fixed HA default', async () => {
+ vi.stubEnv('NEXT_PUBLIC_ENVIRONMENT', 'local')
+ try {
+ mockWizardEndpoints({ availableRegions: AVAILABLE_REGIONS_WITH_FRANKFURT })
+ const onRequest = vi.fn()
+ mockCreateProject(onRequest)
+
+ await renderWizard()
+
+ await fillProjectName('Local HA Region Project')
+ await generateAndWaitForStrongPassword()
+
+ await user.click(await screen.findByRole('switch', { name: 'Enable high availability' }))
+ // Local dev stacks aren't restricted to the fixed HA region, so the user can still
+ // pick a different one from the (unrestricted) list.
+ await selectRegion(/East US/)
+ expect(getSelectTriggerByLabel('Region')).toHaveTextContent('East US (North Virginia)')
+
+ fireEvent.click(screen.getByRole('button', { name: 'Create new project' }))
+
+ await waitFor(() => expect(onRequest).toHaveBeenCalled())
+ expect(onRequest.mock.calls[0][0].region_selection).toMatchObject({ code: 'us-east-1' })
+ } finally {
+ vi.unstubAllEnvs()
+ }
+ })
+
test('forces the high availability region over a manually selected region and restores it', async () => {
vi.stubEnv('NEXT_PUBLIC_ENVIRONMENT', 'staging')
try {