fix(studio): early fail query when x-connection-encrypted is invalid (#35331)

* fix(studio): early fail query when x-connection-encrypted is invalid

* fix(studio): uniformize readDatabase and projectDetails connString handling

* chore: update api types

* chore: add connectionString null option

* fix: only enforce x-connection-encrypted on platform

* chore: refactor connString check in a single point

* chore: fix guard logic

* chore: fix pgMetaGuard

* chore: fix types
This commit is contained in:
Andrew Valleteau
2025-05-08 12:11:03 +02:00
committed by GitHub
parent 0cb08341f6
commit 31aad403de
116 changed files with 181 additions and 142 deletions

View File

@@ -1,6 +1,6 @@
import { QueryKey, useQuery, UseQueryOptions } from '@tanstack/react-query'
import { handleError as handleErrorFetchers, post } from 'data/fetchers'
import { handleError as handleErrorFetchers, isValidConnString, post } from 'data/fetchers'
import { useSelectedProject } from 'hooks/misc/useSelectedProject'
import { MB, PROJECT_STATUS } from 'lib/constants'
import {
@@ -12,7 +12,7 @@ import { sqlKeys } from './keys'
export type ExecuteSqlVariables = {
projectRef?: string
connectionString?: string
connectionString?: string | null
sql: string
queryKey?: QueryKey
handleError?: (error: ResponseError) => { result: any }
@@ -42,6 +42,7 @@ export async function executeSql(
headersInit?: HeadersInit
): Promise<{ result: any }> {
if (!projectRef) throw new Error('projectRef is required')
if (!isValidConnString(connectionString)) throw new Error('Project connection string is required')
const sqlSize = new Blob([sql]).size
// [Joshen] I think the limit is around 1MB from testing, but its not exactly 1MB it seems