Skip to content

Commit 2e443f6

Browse files
committed
fix(data-drains): allow org-account Snowflake identifier with region suffix
The account validation rejected `<orgname>-<acctname>.<region>.<cloud>` because `ACCOUNT_LOCATOR_RE`'s first segment forbade hyphens, while `ACCOUNT_ORG_RE` forbade dots. `normalizeAccountForJwt` already handles this composite form. Widen the first segment of `ACCOUNT_LOCATOR_RE` to allow hyphens so the boundary contract and the runtime schema accept what the JWT layer was already designed to process.
1 parent 5469cdf commit 2e443f6

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

apps/sim/lib/api/contracts/data-drains.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ const BQ_DATASET_RE = /^[A-Za-z0-9_]{1,1024}$/
4141
const BQ_TABLE_RE = /^[\p{L}\p{M}\p{N}\p{Pc}\p{Pd} ]{1,1024}$/u
4242
/** Snowflake account + identifier shapes — mirrored from snowflake.ts. */
4343
const SNOWFLAKE_ACCOUNT_ORG_RE = /^[A-Za-z0-9][A-Za-z0-9_]*(?:-[A-Za-z0-9_]+)+$/
44+
/** First segment allows hyphens so org-account identifiers carrying a region/cloud suffix match. Mirrors snowflake.ts. */
4445
const SNOWFLAKE_ACCOUNT_LOCATOR_RE =
45-
/^[A-Za-z0-9][A-Za-z0-9_]*(?:\.[A-Za-z0-9][A-Za-z0-9_-]*){0,2}$/
46+
/^[A-Za-z0-9][A-Za-z0-9_-]*(?:\.[A-Za-z0-9][A-Za-z0-9_-]*){0,2}$/
4647
const SNOWFLAKE_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_$]{0,254}$/
4748
/** Reserved Sim-namespaced header names that cannot be reused as the webhook signature header. */
4849
const RESERVED_WEBHOOK_SIGNATURE_HEADER_NAMES = new Set([

apps/sim/lib/data-drains/destinations/snowflake.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ const logger = createLogger('DataDrainSnowflakeDestination')
1919
* - Legacy account locator: `<locator>` or `<locator>.<region>[.<cloud>]` — dots allowed.
2020
*/
2121
const ACCOUNT_ORG_RE = /^[A-Za-z0-9][A-Za-z0-9_]*(?:-[A-Za-z0-9_]+)+$/
22-
const ACCOUNT_LOCATOR_RE = /^[A-Za-z0-9][A-Za-z0-9_]*(?:\.[A-Za-z0-9][A-Za-z0-9_-]*){0,2}$/
22+
/**
23+
* First segment allows hyphens so org-account identifiers (`<orgname>-<acctname>`)
24+
* carrying a legacy region/cloud suffix (e.g. `myorg-acct.us-east-1.aws`) match.
25+
* `normalizeAccountForJwt` strips the dotted suffix for JWT `iss`/`sub`.
26+
*/
27+
const ACCOUNT_LOCATOR_RE = /^[A-Za-z0-9][A-Za-z0-9_-]*(?:\.[A-Za-z0-9][A-Za-z0-9_-]*){0,2}$/
2328
function isValidAccount(v: string): boolean {
2429
return ACCOUNT_ORG_RE.test(v) || ACCOUNT_LOCATOR_RE.test(v)
2530
}

0 commit comments

Comments
 (0)