From 9f0ae455378d5ce16dc833bdbea9a4b86607364a Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Fri, 7 Aug 2026 10:49:32 +0530 Subject: [PATCH 01/22] fix(databases): render array column items with their element type The string fallback in the row column renderer exists for the spreadsheet inline cell editor, where an entire array is edited as one comma-separated textarea. It keyed off `column.array` (the column definition) rather than the `array` prop (the render mode). In the full row create/edit form, columnItem renders one Column per array element and deliberately omits the `array` prop so each item gets its element-type input. Since `column.array` was still true, every item collapsed to a string input -- a Boolean[] column showed "Enter string". This also caused intermittent save failures: the string component still ran parseValue() against column.type, so literal true/false/1/0 coerced and saved, while anything else yielded null, and a null inside a typed array is rejected by the API. Keying off the `array` prop restores per-item typed inputs (boolean select, number input with min/max, date picker) while leaving the spreadsheet cell editor and its "Advanced edit" link untouched, since only the two fromSpreadsheet branches pass `array`. --- .../table-[table]/rows/columns/column.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/columns/column.svelte b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/columns/column.svelte index 37947fefe..1f385d75a 100644 --- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/columns/column.svelte +++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/columns/column.svelte @@ -88,7 +88,7 @@ {:else} Date: Fri, 7 Aug 2026 11:14:28 +0530 Subject: [PATCH 02/22] chore(deps): raise the js-yaml floor to 4.3.1 GHSA-5p4m-2wfm-xmqj (CVE-2026-59870) covers >=4.0.0 <4.3.1 and the fix was not backported, so the existing >=4.3.0 override stopped clearing it and the audit step in tests.yml now fails on every branch. It reaches us transitively via eslint > @eslint/eslintrc > js-yaml. Only the pinned floor and the resolved version move; integrity hashes are untouched. --- bun.lock | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bun.lock b/bun.lock index 4f7dcfe95..263bb6ac7 100644 --- a/bun.lock +++ b/bun.lock @@ -95,7 +95,7 @@ "devalue": "^5.8.1", "flatted": "^3.4.2", "immutable": "^5.1.8", - "js-yaml": "^4.3.0", + "js-yaml": "^4.3.1", "minimatch": "10.2.3", "picomatch": "^4.0.4", "postcss": "^8.5.18", @@ -1024,7 +1024,7 @@ "js-tokens": ["js-tokens@4.0.0", "", {}, "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="], - "js-yaml": ["js-yaml@4.3.0", "", { "dependencies": { "argparse": "^2.0.1" }, "bin": { "js-yaml": "bin/js-yaml.js" } }, "sha512-1td788aAnnZ5qs7V2QIRl1owjtYpbKt749Y3xauqQgwIIGF/xXWz1wMTEBx5O3LK3lXLVuqXPdPxj2BoFHaW9Q=="], + "js-yaml": ["js-yaml@4.3.1", "", { "dependencies": { "argparse": "^2.0.1" }, "bin": { "js-yaml": "bin/js-yaml.js" } }, "sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ=="], "jsdom": ["jsdom@26.1.0", "", { "dependencies": { "cssstyle": "^4.2.1", "data-urls": "^5.0.0", "decimal.js": "^10.5.0", "html-encoding-sniffer": "^4.0.0", "http-proxy-agent": "^7.0.2", "https-proxy-agent": "^7.0.6", "is-potential-custom-element-name": "^1.0.1", "nwsapi": "^2.2.16", "parse5": "^7.2.1", "rrweb-cssom": "^0.8.0", "saxes": "^6.0.0", "symbol-tree": "^3.2.4", "tough-cookie": "^5.1.1", "w3c-xmlserializer": "^5.0.0", "webidl-conversions": "^7.0.0", "whatwg-encoding": "^3.1.1", "whatwg-mimetype": "^4.0.0", "whatwg-url": "^14.1.1", "ws": "^8.18.0", "xml-name-validator": "^5.0.0" }, "peerDependencies": { "canvas": "^3.0.0" }, "optionalPeers": ["canvas"] }, "sha512-Cvc9WUhxSMEo4McES3P7oK3QaXldCfNWp7pl2NNeiIFlCoLr3kfq9kb1fxftiwk1FLV7CvpvDfonxtzUDeSOPg=="], diff --git a/package.json b/package.json index c4958f63e..d8a7e51e6 100644 --- a/package.json +++ b/package.json @@ -105,7 +105,7 @@ "vite": "npm:rolldown-vite@latest", "minimatch": "10.2.3", "brace-expansion": ">=5.0.9", - "js-yaml": "^4.3.0", + "js-yaml": "^4.3.1", "immutable": "^5.1.8", "flatted": "^3.4.2", "devalue": "^5.8.1", From 9dde99783019ee763318df2c1a6b04077aa2d6b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 11 Aug 2026 16:32:34 +0200 Subject: [PATCH 03/22] Fix compatibility with external CIMD URLs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Appwrite's apps.get()/apps.list() no longer resolve CIMD URLs — appId is always a plain ID now. Detect URL-shaped OAuth2 client IDs in the console and fetch the Client ID Metadata Document directly from the browser, mapping its RFC 7591 fields onto Models.App for consent/device/applications rendering. Fetch or validation failures fall back to hostname-only branding so the flow never blocks. Co-Authored-By: Claude Fable 5 --- src/lib/helpers/oauth2-cimd.test.ts | 76 ++++++++++ src/lib/helpers/oauth2-cimd.ts | 141 ++++++++++++++++++ .../(console)/account/applications/+page.ts | 4 +- .../(public)/oauth2/consent/+page.svelte | 7 +- .../(public)/oauth2/device/+page.svelte | 5 +- 5 files changed, 224 insertions(+), 9 deletions(-) create mode 100644 src/lib/helpers/oauth2-cimd.test.ts create mode 100644 src/lib/helpers/oauth2-cimd.ts diff --git a/src/lib/helpers/oauth2-cimd.test.ts b/src/lib/helpers/oauth2-cimd.test.ts new file mode 100644 index 000000000..fce9d1b2a --- /dev/null +++ b/src/lib/helpers/oauth2-cimd.test.ts @@ -0,0 +1,76 @@ +import { cimdDocumentToApp, isCimdClientId } from '$lib/helpers/oauth2-cimd'; +import { describe, expect, it } from 'vitest'; + +describe('isCimdClientId', () => { + it('accepts https URLs', () => { + expect(isCimdClientId('https://example.com/oauth/client-metadata.json')).toBe(true); + }); + + it('accepts http only for loopback', () => { + expect(isCimdClientId('http://localhost:3000/client.json')).toBe(true); + expect(isCimdClientId('http://127.0.0.1/client.json')).toBe(true); + expect(isCimdClientId('http://example.com/client.json')).toBe(false); + }); + + it('rejects plain app IDs and non-http schemes', () => { + expect(isCimdClientId('my-app_1.0')).toBe(false); + expect(isCimdClientId('64f1e2a9b3c4d5e6f7a8')).toBe(false); + expect(isCimdClientId('javascript:alert(1)')).toBe(false); + }); +}); + +describe('cimdDocumentToApp', () => { + const clientId = 'https://example.com/oauth/client-metadata.json'; + + it('maps RFC 7591 metadata onto the App model', () => { + const app = cimdDocumentToApp(clientId, { + client_id: clientId, + client_name: 'Example App', + client_uri: 'https://example.com', + logo_uri: 'https://example.com/logo.png', + policy_uri: 'https://example.com/privacy', + tos_uri: 'https://example.com/terms', + contacts: ['support@example.com'], + redirect_uris: ['https://example.com/callback'], + token_endpoint_auth_method: 'none', + grant_types: ['authorization_code', 'urn:ietf:params:oauth:grant-type:device_code'] + }); + + expect(app.$id).toBe(clientId); + expect(app.name).toBe('Example App'); + expect(app.clientUri).toBe('https://example.com'); + expect(app.logoUri).toBe('https://example.com/logo.png'); + expect(app.privacyPolicyUrl).toBe('https://example.com/privacy'); + expect(app.termsUrl).toBe('https://example.com/terms'); + expect(app.contacts).toEqual(['support@example.com']); + expect(app.redirectUris).toEqual(['https://example.com/callback']); + expect(app.type).toBe('public'); + expect(app.deviceFlow).toBe(true); + expect(app.enabled).toBe(true); + }); + + it('falls back to the hostname when client_name is missing', () => { + const app = cimdDocumentToApp(clientId, { client_id: clientId }); + expect(app.name).toBe('example.com'); + expect(app.deviceFlow).toBe(false); + }); + + it('rejects a document whose client_id does not match its URL', () => { + expect(() => + cimdDocumentToApp(clientId, { client_id: 'https://evil.example/other.json' }) + ).toThrow(); + expect(() => cimdDocumentToApp(clientId, 'not an object')).toThrow(); + }); + + it('drops unrenderable URI values', () => { + const app = cimdDocumentToApp(clientId, { + client_id: clientId, + logo_uri: 'javascript:alert(1)', + client_uri: 'not a url', + contacts: ['ok', 42] + }); + expect(app.logoUri).toBe(''); + expect(app.clientUri).toBe(''); + expect(app.contacts).toEqual(['ok']); + }); +}); diff --git a/src/lib/helpers/oauth2-cimd.ts b/src/lib/helpers/oauth2-cimd.ts new file mode 100644 index 000000000..bf0d9881c --- /dev/null +++ b/src/lib/helpers/oauth2-cimd.ts @@ -0,0 +1,141 @@ +import { sdk } from '$lib/stores/sdk'; +import type { Models } from '@appwrite.io/console'; + +/** + * CIMD (Client ID Metadata Document) support: a `client_id` may be an HTTPS + * URL pointing to a JSON document of RFC 7591 client metadata. The Appwrite + * API no longer resolves these — `apps.get()` accepts plain app IDs only — so + * the console fetches the document itself for consent-screen branding. The + * server still validates the client during authorization, so a failed fetch + * only degrades branding, never security. + */ + +const FETCH_TIMEOUT = 10_000; + +const DEVICE_GRANT_TYPE = 'urn:ietf:params:oauth:grant-type:device_code'; + +/** The RFC 7591 metadata fields the console renders. */ +type CimdDocument = { + client_id?: unknown; + client_name?: unknown; + client_uri?: unknown; + logo_uri?: unknown; + policy_uri?: unknown; + tos_uri?: unknown; + contacts?: unknown; + redirect_uris?: unknown; + post_logout_redirect_uris?: unknown; + token_endpoint_auth_method?: unknown; + grant_types?: unknown; +}; + +function isLoopback(hostname: string): boolean { + return hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '[::1]'; +} + +/** + * Plain app IDs are at most 36 chars of `[a-zA-Z0-9._-]` and never parse as + * absolute URLs, so anything URL-shaped is a CIMD client_id. HTTP is only + * accepted for loopback (local development). + */ +export function isCimdClientId(clientId: string): boolean { + let url: URL; + try { + url = new URL(clientId); + } catch { + return false; + } + return url.protocol === 'https:' || (url.protocol === 'http:' && isLoopback(url.hostname)); +} + +/** Documents are untrusted input — only pass through values safe to render in href/src. */ +function httpUrl(value: unknown): string { + if (typeof value !== 'string') return ''; + try { + const url = new URL(value); + return url.protocol === 'https:' || url.protocol === 'http:' ? value : ''; + } catch { + return ''; + } +} + +function stringArray(value: unknown): string[] { + return Array.isArray(value) ? value.filter((item) => typeof item === 'string') : []; +} + +/** A minimal app so consent can still render when the document is unavailable. */ +function fallbackApp(clientId: string): Models.App { + return { + $id: clientId, + $createdAt: '', + $updatedAt: '', + name: new URL(clientId).hostname, + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'public', + deviceFlow: false, + teamId: '', + userId: '', + secrets: [] + }; +} + +export function cimdDocumentToApp(clientId: string, document: unknown): Models.App { + if (typeof document !== 'object' || document === null) { + throw new Error('CIMD document is not a JSON object'); + } + const doc = document as CimdDocument; + // The document's client_id MUST equal the URL it was fetched from — a + // mismatch means the document describes a different client. + if (doc.client_id !== clientId) { + throw new Error('CIMD document client_id does not match its URL'); + } + const name = typeof doc.client_name === 'string' ? doc.client_name.trim() : ''; + return { + ...fallbackApp(clientId), + name: name || new URL(clientId).hostname, + clientUri: httpUrl(doc.client_uri), + logoUri: httpUrl(doc.logo_uri), + privacyPolicyUrl: httpUrl(doc.policy_uri), + termsUrl: httpUrl(doc.tos_uri), + contacts: stringArray(doc.contacts), + redirectUris: stringArray(doc.redirect_uris), + postLogoutRedirectUris: stringArray(doc.post_logout_redirect_uris), + type: doc.token_endpoint_auth_method === 'none' ? 'public' : 'confidential', + deviceFlow: stringArray(doc.grant_types).includes(DEVICE_GRANT_TYPE) + }; +} + +/** + * Resolve an app for display: plain IDs via the API, CIMD URLs by fetching + * the document directly. CIMD fetch/validation failures fall back to + * hostname-only branding rather than blocking the flow. + */ +export async function getOAuth2App(appId: string): Promise { + if (!isCimdClientId(appId)) { + return sdk.forConsole.apps.get({ appId }); + } + try { + const response = await fetch(appId, { + headers: { accept: 'application/json' }, + credentials: 'omit', + signal: AbortSignal.timeout(FETCH_TIMEOUT) + }); + if (!response.ok) throw new Error(`CIMD document request failed: ${response.status}`); + return cimdDocumentToApp(appId, await response.json()); + } catch { + return fallbackApp(appId); + } +} diff --git a/src/routes/(console)/account/applications/+page.ts b/src/routes/(console)/account/applications/+page.ts index 14645b446..c453ee958 100644 --- a/src/routes/(console)/account/applications/+page.ts +++ b/src/routes/(console)/account/applications/+page.ts @@ -1,5 +1,5 @@ import { Dependencies } from '$lib/constants'; -import { sdk } from '$lib/stores/sdk'; +import { getOAuth2App } from '$lib/helpers/oauth2-cimd'; import type { Models } from '@appwrite.io/console'; import type { PageLoad } from './$types'; @@ -19,7 +19,7 @@ export const load: PageLoad = async ({ depends, parent }) => { const connectedApps = await Promise.all( grants.map(async (identity) => { const appId = identity.provider.slice(OAUTH2_PREFIX.length); - const app = await sdk.forConsole.apps.get({ appId }).catch(() => null); + const app = await getOAuth2App(appId).catch(() => null); return { identity, appId, app }; }) ); diff --git a/src/routes/(public)/oauth2/consent/+page.svelte b/src/routes/(public)/oauth2/consent/+page.svelte index 81553b172..0599bd277 100644 --- a/src/routes/(public)/oauth2/consent/+page.svelte +++ b/src/routes/(public)/oauth2/consent/+page.svelte @@ -9,6 +9,7 @@ import { sdk } from '$lib/stores/sdk'; import { logout } from '$lib/helpers/logout'; import { isWebRedirect } from '$lib/helpers/oauth2-redirect'; + import { getOAuth2App } from '$lib/helpers/oauth2-cimd'; import OAuth2ConsentCard, { type OAuth2Outcome } from '../consent-card.svelte'; import OAuth2OutcomeCard from '../outcome-card.svelte'; import { OAuth2ErrorMessage, OAuth2ErrorType } from '../errors'; @@ -85,7 +86,7 @@ ): Promise { const loadedGrant = await sdk.forConsole.oauth2.getGrant({ grantId }); const [loadedApp, loadedAccount] = await Promise.all([ - sdk.forConsole.apps.get({ appId: loadedGrant.appId }), + getOAuth2App(loadedGrant.appId), knownAccount !== undefined ? Promise.resolve(knownAccount) : getAccount() ]); if (cancelled()) return; @@ -122,9 +123,7 @@ if (!isWebRedirect(result.redirectUrl)) { completedRedirectUrl = result.redirectUrl; account = loggedInAccount; - app = clientId - ? await sdk.forConsole.apps.get({ appId: clientId }).catch(() => null) - : null; + app = clientId ? await getOAuth2App(clientId).catch(() => null) : null; if (cancelled()) return; phase = 'approved'; } diff --git a/src/routes/(public)/oauth2/device/+page.svelte b/src/routes/(public)/oauth2/device/+page.svelte index 15f37b0d4..15e0c43c0 100644 --- a/src/routes/(public)/oauth2/device/+page.svelte +++ b/src/routes/(public)/oauth2/device/+page.svelte @@ -10,6 +10,7 @@ import { addNotification } from '$lib/stores/notifications'; import { sdk } from '$lib/stores/sdk'; import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; + import { getOAuth2App } from '$lib/helpers/oauth2-cimd'; import OAuth2ConsentCard, { type OAuth2Flow, type OAuth2Outcome } from '../consent-card.svelte'; import OAuth2OutcomeCard from '../outcome-card.svelte'; @@ -95,9 +96,7 @@ const loadedGrant = await sdk.forConsole.oauth2.createGrant({ userCode: normalized }); - const loadedApp = await sdk.forConsole.apps.get({ - appId: loadedGrant.appId - }); + const loadedApp = await getOAuth2App(loadedGrant.appId); // A fresh `user_code` may have arrived while we awaited. Ignore this // now-stale result so we never show consent for a superseded request. if (normalizeUserCode(code) !== normalized) return; From 8ed7be09ae76994ac8ba99b25e0d338ddafcb0ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 11 Aug 2026 16:36:53 +0200 Subject: [PATCH 04/22] refactor(oauth2): inline the one-off CIMD helpers Co-Authored-By: Claude Fable 5 --- src/lib/helpers/oauth2-cimd.ts | 133 +++++++++++++-------------------- 1 file changed, 50 insertions(+), 83 deletions(-) diff --git a/src/lib/helpers/oauth2-cimd.ts b/src/lib/helpers/oauth2-cimd.ts index bf0d9881c..7d631f678 100644 --- a/src/lib/helpers/oauth2-cimd.ts +++ b/src/lib/helpers/oauth2-cimd.ts @@ -1,20 +1,14 @@ import { sdk } from '$lib/stores/sdk'; import type { Models } from '@appwrite.io/console'; -/** - * CIMD (Client ID Metadata Document) support: a `client_id` may be an HTTPS - * URL pointing to a JSON document of RFC 7591 client metadata. The Appwrite - * API no longer resolves these — `apps.get()` accepts plain app IDs only — so - * the console fetches the document itself for consent-screen branding. The - * server still validates the client during authorization, so a failed fetch - * only degrades branding, never security. - */ +// CIMD (Client ID Metadata Document): a client_id may be an HTTPS URL pointing +// to a JSON document of RFC 7591 client metadata. The Appwrite API no longer +// resolves these, so the console fetches the document itself for branding. const FETCH_TIMEOUT = 10_000; - const DEVICE_GRANT_TYPE = 'urn:ietf:params:oauth:grant-type:device_code'; +const HTTP_URL = /^https?:\/\//i; -/** The RFC 7591 metadata fields the console renders. */ type CimdDocument = { client_id?: unknown; client_name?: unknown; @@ -29,67 +23,17 @@ type CimdDocument = { grant_types?: unknown; }; -function isLoopback(hostname: string): boolean { - return hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '[::1]'; -} - -/** - * Plain app IDs are at most 36 chars of `[a-zA-Z0-9._-]` and never parse as - * absolute URLs, so anything URL-shaped is a CIMD client_id. HTTP is only - * accepted for loopback (local development). - */ +// Plain app IDs never parse as URLs; http is allowed for local development only. export function isCimdClientId(clientId: string): boolean { - let url: URL; try { - url = new URL(clientId); + const url = new URL(clientId); + return ( + url.protocol === 'https:' || + (url.protocol === 'http:' && ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname)) + ); } catch { return false; } - return url.protocol === 'https:' || (url.protocol === 'http:' && isLoopback(url.hostname)); -} - -/** Documents are untrusted input — only pass through values safe to render in href/src. */ -function httpUrl(value: unknown): string { - if (typeof value !== 'string') return ''; - try { - const url = new URL(value); - return url.protocol === 'https:' || url.protocol === 'http:' ? value : ''; - } catch { - return ''; - } -} - -function stringArray(value: unknown): string[] { - return Array.isArray(value) ? value.filter((item) => typeof item === 'string') : []; -} - -/** A minimal app so consent can still render when the document is unavailable. */ -function fallbackApp(clientId: string): Models.App { - return { - $id: clientId, - $createdAt: '', - $updatedAt: '', - name: new URL(clientId).hostname, - description: '', - clientUri: '', - logoUri: '', - privacyPolicyUrl: '', - termsUrl: '', - contacts: [], - tagline: '', - tags: [], - images: [], - supportUrl: '', - dataDeletionUrl: '', - redirectUris: [], - postLogoutRedirectUris: [], - enabled: true, - type: 'public', - deviceFlow: false, - teamId: '', - userId: '', - secrets: [] - }; } export function cimdDocumentToApp(clientId: string, document: unknown): Models.App { @@ -97,32 +41,55 @@ export function cimdDocumentToApp(clientId: string, document: unknown): Models.A throw new Error('CIMD document is not a JSON object'); } const doc = document as CimdDocument; - // The document's client_id MUST equal the URL it was fetched from — a - // mismatch means the document describes a different client. + // The document's client_id must equal the URL it was fetched from. if (doc.client_id !== clientId) { throw new Error('CIMD document client_id does not match its URL'); } const name = typeof doc.client_name === 'string' ? doc.client_name.trim() : ''; return { - ...fallbackApp(clientId), + $id: clientId, + $createdAt: '', + $updatedAt: '', name: name || new URL(clientId).hostname, - clientUri: httpUrl(doc.client_uri), - logoUri: httpUrl(doc.logo_uri), - privacyPolicyUrl: httpUrl(doc.policy_uri), - termsUrl: httpUrl(doc.tos_uri), - contacts: stringArray(doc.contacts), - redirectUris: stringArray(doc.redirect_uris), - postLogoutRedirectUris: stringArray(doc.post_logout_redirect_uris), + description: '', + // Untrusted values rendered in href/src must be http(s) URLs. + clientUri: + typeof doc.client_uri === 'string' && HTTP_URL.test(doc.client_uri) + ? doc.client_uri + : '', + logoUri: + typeof doc.logo_uri === 'string' && HTTP_URL.test(doc.logo_uri) ? doc.logo_uri : '', + privacyPolicyUrl: + typeof doc.policy_uri === 'string' && HTTP_URL.test(doc.policy_uri) + ? doc.policy_uri + : '', + termsUrl: typeof doc.tos_uri === 'string' && HTTP_URL.test(doc.tos_uri) ? doc.tos_uri : '', + contacts: Array.isArray(doc.contacts) + ? doc.contacts.filter((contact) => typeof contact === 'string') + : [], + tagline: '', + tags: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: Array.isArray(doc.redirect_uris) + ? doc.redirect_uris.filter((uri) => typeof uri === 'string') + : [], + postLogoutRedirectUris: Array.isArray(doc.post_logout_redirect_uris) + ? doc.post_logout_redirect_uris.filter((uri) => typeof uri === 'string') + : [], + enabled: true, type: doc.token_endpoint_auth_method === 'none' ? 'public' : 'confidential', - deviceFlow: stringArray(doc.grant_types).includes(DEVICE_GRANT_TYPE) + deviceFlow: Array.isArray(doc.grant_types) && doc.grant_types.includes(DEVICE_GRANT_TYPE), + teamId: '', + userId: '', + secrets: [] }; } -/** - * Resolve an app for display: plain IDs via the API, CIMD URLs by fetching - * the document directly. CIMD fetch/validation failures fall back to - * hostname-only branding rather than blocking the flow. - */ +// Plain IDs resolve via the API; CIMD URLs are fetched directly. Fetch or +// validation failures fall back to hostname-only branding rather than blocking +// the flow — the server still validates the client during authorization. export async function getOAuth2App(appId: string): Promise { if (!isCimdClientId(appId)) { return sdk.forConsole.apps.get({ appId }); @@ -136,6 +103,6 @@ export async function getOAuth2App(appId: string): Promise { if (!response.ok) throw new Error(`CIMD document request failed: ${response.status}`); return cimdDocumentToApp(appId, await response.json()); } catch { - return fallbackApp(appId); + return cimdDocumentToApp(appId, { client_id: appId }); } } From 6b7c35ae15314a569fc9203b731b3d6039663b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 11 Aug 2026 16:44:21 +0200 Subject: [PATCH 05/22] chore(deps): raise the nanoid floor past GHSA-28wg-ghj8-5hjv and GHSA-2v37-7h3g-55p8 bun audit fails the CI build on three high nanoid advisories. All fixes are within the existing semver ranges: the direct dependency and @melt-ui/svelte's nested copy move to 5.1.16, and the 3.x copies under @ai-sdk/provider-utils and postcss move to 3.3.17. Co-Authored-By: Claude Fable 5 --- bun.lock | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bun.lock b/bun.lock index 263bb6ac7..eed9e9aa4 100644 --- a/bun.lock +++ b/bun.lock @@ -37,7 +37,7 @@ "flatted": "^3.4.2", "ignore": "^6.0.2", "json5": "^2.2.3", - "nanoid": "^5.1.11", + "nanoid": "^5.1.16", "nanotar": "^0.3.0", "pretty-bytes": "^6.1.1", "remarkable": "^2.0.1", @@ -1128,7 +1128,7 @@ "ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="], - "nanoid": ["nanoid@5.1.11", "", { "bin": { "nanoid": "bin/nanoid.js" } }, "sha512-v+KEsUv2ps74PaSKv0gHTxTCgMXOIfBEbaqa6w6ISIGC7ZsvHN4N9oJ8d4cmf0n5oTzQz2SLmThbQWhjd/8eKg=="], + "nanoid": ["nanoid@5.1.16", "", { "bin": { "nanoid": "bin/nanoid.js" } }, "sha512-kVrnsrJqMR8+oLJnGEmSWw9BivK5mt7H3FZatVRjrc5wGqFYuBxX1yG7+A7Gi5AefkX6t/oCkizcQgpu0cY1dQ=="], "nanotar": ["nanotar@0.3.0", "", {}, "sha512-Kv2JYYiCzt16Kt5QwAc9BFG89xfPNBx+oQL4GQXD9nLqPkZBiNaqaCWtwnbk/q7UVsTYevvM1b0UF8zmEI4pCg=="], @@ -1500,7 +1500,7 @@ "@ai-sdk/provider-utils/@ai-sdk/provider": ["@ai-sdk/provider@1.0.11", "", { "dependencies": { "json-schema": "^0.4.0" } }, "sha512-CPyImHGiT3svyfmvPvAFTianZzWFtm0qK82XjwlQIA1C3IQ2iku/PMQXi7aFyrX0TyMh3VTkJPB03tjU2VXVrw=="], - "@ai-sdk/provider-utils/nanoid": ["nanoid@3.3.11", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w=="], + "@ai-sdk/provider-utils/nanoid": ["nanoid@3.3.17", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-xQLf0A3HOMlgHq0n247/LRuAOYmB7dXJ/DvAxGvsSBij45XtBSmQycu+F8ODbHwns/XyFZagyL1+J0Offw1E0g=="], "@ai-sdk/ui-utils/@ai-sdk/provider": ["@ai-sdk/provider@1.0.11", "", { "dependencies": { "json-schema": "^0.4.0" } }, "sha512-CPyImHGiT3svyfmvPvAFTianZzWFtm0qK82XjwlQIA1C3IQ2iku/PMQXi7aFyrX0TyMh3VTkJPB03tjU2VXVrw=="], @@ -1524,7 +1524,7 @@ "@eslint/eslintrc/ignore": ["ignore@5.3.2", "", {}, "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g=="], - "@melt-ui/svelte/nanoid": ["nanoid@5.1.7", "", { "bin": { "nanoid": "bin/nanoid.js" } }, "sha512-ua3NDgISf6jdwezAheMOk4mbE1LXjm1DfMUDMuJf4AqxLFK3ccGpgWizwa5YV7Yz9EpXwEaWoRXSb/BnV0t5dQ=="], + "@melt-ui/svelte/nanoid": ["nanoid@5.1.16", "", { "bin": { "nanoid": "bin/nanoid.js" } }, "sha512-kVrnsrJqMR8+oLJnGEmSWw9BivK5mt7H3FZatVRjrc5wGqFYuBxX1yG7+A7Gi5AefkX6t/oCkizcQgpu0cY1dQ=="], "@opentelemetry/core/@opentelemetry/semantic-conventions": ["@opentelemetry/semantic-conventions@1.28.0", "", {}, "sha512-lp4qAiMTD4sNWW4DbKLBkfiMZ4jbAboJIGOQr5DvciMRI494OapieI9qiODpOt0XBr1LjIDy1xAGAnVs5supTA=="], @@ -1574,7 +1574,7 @@ "popmotion/tslib": ["tslib@2.4.0", "", {}, "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ=="], - "postcss/nanoid": ["nanoid@3.3.16", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-bzlKTyNJ7+LdGIIwy8ijFpIqEQIvafahV7eYykJ8Cvh42EdJeODoJ6gUJXpQJvej1BddH8OqTXZNE/KfbWAu8Q=="], + "postcss/nanoid": ["nanoid@3.3.17", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-xQLf0A3HOMlgHq0n247/LRuAOYmB7dXJ/DvAxGvsSBij45XtBSmQycu+F8ODbHwns/XyFZagyL1+J0Offw1E0g=="], "style-value-types/tslib": ["tslib@2.4.0", "", {}, "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ=="], diff --git a/package.json b/package.json index d8a7e51e6..86727369c 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "flatted": "^3.4.2", "ignore": "^6.0.2", "json5": "^2.2.3", - "nanoid": "^5.1.11", + "nanoid": "^5.1.16", "nanotar": "^0.3.0", "pretty-bytes": "^6.1.1", "remarkable": "^2.0.1", From 1d4cfad9fadc737307fbc9a54b02df3d5207a6a4 Mon Sep 17 00:00:00 2001 From: Levi van Noort <73097785+levivannoort@users.noreply.github.com> Date: Wed, 12 Aug 2026 06:38:45 +0200 Subject: [PATCH 06/22] fix(variables): validate variable keys before writing them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The API now rejects variable keys that are not valid environment variable names, but the console had no key validation anywhere — only a value length check. Keys with hyphens, dots, spaces or a leading digit reached the API and came back as a bare server error, and three flows handled that badly: - create-function and create-site create the resource (and its proxy rule) before the variables, so a rejected key left a function or site with no deployment behind - the update modal resends the stored key on a value-only edit, so a key stored before the rule existed could no longer have its value changed - promote-to-global deletes the existing global variable before creating its replacement, so a rejected key destroyed the original Add a shared validator and check keys before submitting, in every entry point that writes them. Send the key on update only when it changed, so the API keeps the stored one and existing keys stay editable. Flag keys that cannot be used as environment variable names in the variables tables, since those are ignored at build and runtime. Report per-key failures from the batch writes instead of a single rejection. Server-side rule: appwrite/appwrite#13181 Co-Authored-By: Claude Opus 5 (1M context) --- .../variables/createVariableModal.svelte | 15 +++-- .../variables/environmentVariables.svelte | 24 ++++++- .../variables/importVariablesModal.svelte | 10 +-- .../variables/updateVariableModal.svelte | 11 +++- .../variables/variableEditorModal.svelte | 10 +-- src/lib/helpers/variables.test.ts | 49 ++++++++++++++ src/lib/helpers/variables.ts | 66 +++++++++++++++++++ .../createVariableModal.svelte | 19 ++++-- .../create-function/deploy/+page.svelte | 8 +++ .../create-function/manual/+page.svelte | 8 +++ .../repository-[repository]/+page.svelte | 13 +++- .../template-[template]/+page.svelte | 10 +++ .../rawVariableEditor.svelte | 39 ++++++++--- .../sites/create-site/deploy/+page.svelte | 8 +++ .../sites/create-site/manual/+page.svelte | 8 +++ .../repository-[repository]/+page.svelte | 13 +++- .../template-[template]/+page.svelte | 10 +++ .../updateVariables.svelte | 50 ++++++++++++-- .../updateVariablesModal.svelte | 22 ++++++- .../uploadVariablesModal.svelte | 30 ++++++--- 20 files changed, 375 insertions(+), 48 deletions(-) create mode 100644 src/lib/helpers/variables.test.ts diff --git a/src/lib/components/variables/createVariableModal.svelte b/src/lib/components/variables/createVariableModal.svelte index 06b73ea54..5ba5ef4c6 100644 --- a/src/lib/components/variables/createVariableModal.svelte +++ b/src/lib/components/variables/createVariableModal.svelte @@ -8,6 +8,7 @@ import { Link } from '$lib/elements'; import { page } from '$app/state'; import { IconPlus, IconX } from '@appwrite.io/pink-icons-svelte'; + import { validateVariables } from '$lib/helpers/variables'; export type ProductLabel = 'site' | 'function'; @@ -39,13 +40,13 @@ newVariables = newVariables.map((variable) => ({ ...variable, secret: true })); } - newVariables.forEach((variable) => { - if (('' + variable.value).length > 8192) { - throw new Error( - `Variable ${variable.key} is longer than 8192 allowed characters` - ); - } - }); + const validationError = validateVariables( + newVariables.filter((variable) => variable.key || variable.value) + ); + if (validationError) { + throw new Error(validationError); + } + const updatedVariables = [...variables]; newVariables.forEach((newVar) => { if (!newVar.key) { diff --git a/src/lib/components/variables/environmentVariables.svelte b/src/lib/components/variables/environmentVariables.svelte index 595cc08ac..88dddf301 100644 --- a/src/lib/components/variables/environmentVariables.svelte +++ b/src/lib/components/variables/environmentVariables.svelte @@ -22,6 +22,7 @@ import UpdateVariableModal from './updateVariableModal.svelte'; import { Click, trackEvent } from '$lib/actions/analytics'; import { isSmallViewport } from '$lib/stores/viewport'; + import { isValidVariableKey } from '$lib/helpers/variables'; const DOCS_LINKS: Record = { site: 'https://appwrite.io/docs/products/sites/develop#accessing-environment-variables', @@ -146,7 +147,28 @@ {#each paginatedItems as variable} - {variable.key} + + + {#if !isValidVariableKey(variable.key)} + + + + This key can't be used as an environment + variable name. Rename it using only letters, + digits and underscores, without starting + with a digit. + + + {/if} + {variable.key} + +
diff --git a/src/lib/components/variables/importVariablesModal.svelte b/src/lib/components/variables/importVariablesModal.svelte index 9f0b782d1..8ff09d62a 100644 --- a/src/lib/components/variables/importVariablesModal.svelte +++ b/src/lib/components/variables/importVariablesModal.svelte @@ -7,6 +7,7 @@ import { Icon, Layout, Selector, Tooltip, Typography, Upload } from '@appwrite.io/pink-svelte'; import { parse } from '$lib/helpers/envfile'; import { removeFile } from '$lib/helpers/files'; + import { validateVariables } from '$lib/helpers/variables'; export let show = false; export let variables: Partial[]; @@ -37,10 +38,11 @@ } const entries = Object.entries(uploaded); - for (const [key, value] of entries) { - if (value.length > 8192) { - throw new Error(`Variable ${key} is longer than 8192 allowed characters`); - } + const validationError = validateVariables( + entries.map(([key, value]) => ({ key, value })) + ); + if (validationError) { + throw new Error(validationError); } entries diff --git a/src/lib/components/variables/updateVariableModal.svelte b/src/lib/components/variables/updateVariableModal.svelte index 7d02391fa..005ec89ba 100644 --- a/src/lib/components/variables/updateVariableModal.svelte +++ b/src/lib/components/variables/updateVariableModal.svelte @@ -7,6 +7,7 @@ import { Layout, Selector } from '@appwrite.io/pink-svelte'; import { Link } from '$lib/elements'; import { page } from '$app/state'; + import { validateVariables } from '$lib/helpers/variables'; export let show = false; export let selectedVar: Partial; @@ -20,7 +21,15 @@ secret: selectedVar?.secret }; + let error = ''; + function handleVariable() { + const validationError = validateVariables([pair]); + if (validationError) { + error = validationError; + return; + } + if (selectedVar) { variables = variables.map((variable) => { const match = selectedVar.$id @@ -39,7 +48,7 @@ } - + Update the environment variable for your {productLabel}. Global variables can be set in 8192) { - throw new Error(`Variable ${key} is longer than 8192 allowed characters`); - } + const validationError = validateVariables( + entries.map(([key, value]) => ({ key, value })) + ); + if (validationError) { + throw new Error(validationError); } // Update or remove editable variables diff --git a/src/lib/helpers/variables.test.ts b/src/lib/helpers/variables.test.ts new file mode 100644 index 000000000..75f431a88 --- /dev/null +++ b/src/lib/helpers/variables.test.ts @@ -0,0 +1,49 @@ +import { expect, test } from 'vitest'; +import { + getVariableKeyError, + isValidVariableKey, + validateVariables, + VARIABLE_KEY_MAX_LENGTH, + VARIABLE_VALUE_MAX_LENGTH +} from '$lib/helpers/variables'; + +test('accept keys that are valid environment variable names', () => { + expect(isValidVariableKey('APP_TEST')).toBe(true); + expect(isValidVariableKey('_PRIVATE')).toBe(true); + expect(isValidVariableKey('key1')).toBe(true); + expect(isValidVariableKey('a'.repeat(VARIABLE_KEY_MAX_LENGTH))).toBe(true); +}); + +test('reject keys that cannot be used as environment variable names', () => { + expect(isValidVariableKey('MY-KEY')).toBe(false); + expect(isValidVariableKey('MY.KEY')).toBe(false); + expect(isValidVariableKey('MY KEY')).toBe(false); + expect(isValidVariableKey('9KEY')).toBe(false); + expect(isValidVariableKey('KÉY')).toBe(false); + expect(isValidVariableKey('KEY\t')).toBe(false); + expect(isValidVariableKey('')).toBe(false); + expect(isValidVariableKey('a'.repeat(VARIABLE_KEY_MAX_LENGTH + 1))).toBe(false); +}); + +test('report a missing key separately from an invalid one', () => { + expect(getVariableKeyError('')).toEqual('Variable key is required'); + expect(getVariableKeyError('MY-KEY')).toContain('is invalid'); + expect(getVariableKeyError('a'.repeat(VARIABLE_KEY_MAX_LENGTH + 1))).toContain('longer than'); + expect(getVariableKeyError('APP_TEST')).toBeNull(); +}); + +test('validate a list of variables and name the offending key', () => { + expect(validateVariables([{ key: 'APP_TEST', value: 'value' }])).toBeNull(); + expect(validateVariables([{ key: 'APP_TEST', value: '' }])).toBeNull(); + + expect( + validateVariables([ + { key: 'APP_TEST', value: 'value' }, + { key: 'MY-KEY', value: 'value' } + ]) + ).toContain('MY-KEY'); + + expect( + validateVariables([{ key: 'APP_TEST', value: 'v'.repeat(VARIABLE_VALUE_MAX_LENGTH + 1) }]) + ).toContain('APP_TEST'); +}); diff --git a/src/lib/helpers/variables.ts b/src/lib/helpers/variables.ts index 90219499e..e93e25620 100644 --- a/src/lib/helpers/variables.ts +++ b/src/lib/helpers/variables.ts @@ -1,5 +1,71 @@ import type { Models } from '@appwrite.io/console'; +export const VARIABLE_KEY_MAX_LENGTH = 255; +export const VARIABLE_VALUE_MAX_LENGTH = 8192; + +/** + * Variable keys become environment variable names at build and runtime, so the + * API only accepts C-style identifiers. Keys stored before that rule existed + * can still fail this check, which is why `isValidVariableKey` is also used to + * flag them in the variables table. + */ +const VARIABLE_KEY_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/; + +export function isValidVariableKey(key: string): boolean { + return ( + typeof key === 'string' && + key.length <= VARIABLE_KEY_MAX_LENGTH && + VARIABLE_KEY_PATTERN.test(key) + ); +} + +export function getVariableKeyError(key: string): string | null { + if (!key) { + return 'Variable key is required'; + } + + if (key.length > VARIABLE_KEY_MAX_LENGTH) { + return `Variable key "${key}" is longer than ${VARIABLE_KEY_MAX_LENGTH} allowed characters`; + } + + if (!VARIABLE_KEY_PATTERN.test(key)) { + return `Variable key "${key}" is invalid. Keys can only contain letters, digits and underscores, and cannot start with a digit`; + } + + return null; +} + +export function getVariableValueError(key: string, value: unknown): string | null { + if (('' + (value ?? '')).length > VARIABLE_VALUE_MAX_LENGTH) { + return `Variable ${key} is longer than ${VARIABLE_VALUE_MAX_LENGTH} allowed characters`; + } + + return null; +} + +/** + * Returns the first problem found, or null when every variable is accepted by + * the API. Call before submitting so a rejected key is reported against the + * file or row it came from instead of as a bare server error. + */ +export function validateVariables( + variables: Array<{ key?: string; value?: unknown }> +): string | null { + for (const { key, value } of variables) { + const keyError = getVariableKeyError(key); + if (keyError) { + return keyError; + } + + const valueError = getVariableValueError(key, value); + if (valueError) { + return valueError; + } + } + + return null; +} + export function normalizeDetectedVariables( detected: Models.DetectionVariable[] = [] ): Partial[] { diff --git a/src/routes/(console)/project-[region]-[project]/createVariableModal.svelte b/src/routes/(console)/project-[region]-[project]/createVariableModal.svelte index 2696db0fb..4136fcb18 100644 --- a/src/routes/(console)/project-[region]-[project]/createVariableModal.svelte +++ b/src/routes/(console)/project-[region]-[project]/createVariableModal.svelte @@ -9,12 +9,14 @@ import { Alert, Layout, Selector, Button as PinkButton, Icon } from '@appwrite.io/pink-svelte'; import { Link } from '$lib/elements'; import { IconPlus, IconX } from '@appwrite.io/pink-icons-svelte'; + import { validateVariables } from '$lib/helpers/variables'; export let isGlobal: boolean; export let product: 'function' | 'site' = 'function'; export let showCreate = false; let newVariables: Partial[] = [{ key: '', value: '' }]; let secret = false; + let error = ''; const dispatch = createEventDispatcher(); @@ -26,12 +28,16 @@ if (secret) { newVariables = newVariables.map((variable) => ({ ...variable, secret: true })); } - newVariables.forEach((variable) => { - if (('' + variable.value).length > 8192) { - throw new Error(`Variable ${variable.key} is longer than 8192 allowed characters`); - } - }); - dispatch('created', newVariables); + + const filled = newVariables.filter((variable) => variable.key || variable.value); + + const validationError = validateVariables(filled); + if (validationError) { + error = validationError; + return; + } + + dispatch('created', filled); close(); } @@ -48,6 +54,7 @@ diff --git a/src/routes/(console)/project-[region]-[project]/functions/create-function/deploy/+page.svelte b/src/routes/(console)/project-[region]-[project]/functions/create-function/deploy/+page.svelte index ea90fd2b9..cb7a36047 100644 --- a/src/routes/(console)/project-[region]-[project]/functions/create-function/deploy/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/functions/create-function/deploy/+page.svelte @@ -25,6 +25,7 @@ import { getLatestTag } from '$lib/helpers/github'; import { writable } from 'svelte/store'; import Link from '$lib/elements/link.svelte'; + import { validateVariables } from '$lib/helpers/variables'; let { data @@ -97,6 +98,13 @@ $isSubmitting = true; try { + // Reject an unusable key before the resource is created, so a + // rejected variable can't leave a half-configured resource behind. + const validationError = validateVariables(variables); + if (validationError) { + throw new Error(validationError); + } + if (!latestTag) { latestTag = await getLatestTag(data.repository.owner, data.repository.name); } diff --git a/src/routes/(console)/project-[region]-[project]/functions/create-function/manual/+page.svelte b/src/routes/(console)/project-[region]-[project]/functions/create-function/manual/+page.svelte index 1e7296206..f49a5ded7 100644 --- a/src/routes/(console)/project-[region]-[project]/functions/create-function/manual/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/functions/create-function/manual/+page.svelte @@ -28,6 +28,7 @@ import { humanFileSize } from '$lib/helpers/sizeConvertion'; import { currentPlan } from '$lib/stores/organization'; import { uploader } from '$lib/stores/uploader'; + import { validateVariables } from '$lib/helpers/variables'; export let data; @@ -69,6 +70,13 @@ let func: Models.Function | null = null; try { + // Reject an unusable key before the resource is created, so a + // rejected variable can't leave a half-configured resource behind. + const validationError = validateVariables(variables); + if (validationError) { + throw new Error(validationError); + } + func = await sdk.forProject(page.params.region, page.params.project).functions.create({ functionId: id || ID.unique(), name, diff --git a/src/routes/(console)/project-[region]-[project]/functions/create-function/repository-[repository]/+page.svelte b/src/routes/(console)/project-[region]-[project]/functions/create-function/repository-[repository]/+page.svelte index 0e022aabc..0444fb1bd 100644 --- a/src/routes/(console)/project-[region]-[project]/functions/create-function/repository-[repository]/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/functions/create-function/repository-[repository]/+page.svelte @@ -22,7 +22,11 @@ import RepoCard from './repoCard.svelte'; import { getIconFromRuntime } from '$lib/stores/runtimes'; import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store'; - import { normalizeDetectedVariables, mergeVariables } from '$lib/helpers/variables'; + import { + normalizeDetectedVariables, + mergeVariables, + validateVariables + } from '$lib/helpers/variables'; export let data; @@ -104,6 +108,13 @@ async function create() { try { + // Reject an unusable key before the resource is created, so a + // rejected variable can't leave a half-configured resource behind. + const validationError = validateVariables(variables); + if (validationError) { + throw new Error(validationError); + } + const func = await sdk .forProject(page.params.region, page.params.project) .functions.create({ diff --git a/src/routes/(console)/project-[region]-[project]/functions/create-function/template-[template]/+page.svelte b/src/routes/(console)/project-[region]-[project]/functions/create-function/template-[template]/+page.svelte index a06b57802..2a09f6814 100644 --- a/src/routes/(console)/project-[region]-[project]/functions/create-function/template-[template]/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/functions/create-function/template-[template]/+page.svelte @@ -38,6 +38,7 @@ import { getIconFromRuntime } from '$lib/stores/runtimes'; import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store'; import type { PageData } from './$types'; + import { validateVariables } from '$lib/helpers/variables'; let { data }: { data: PageData } = $props(); @@ -148,6 +149,15 @@ return; } else { try { + // Reject an unusable key before the resource is created, so a + // rejected variable can't leave a half-configured resource behind. + const validationError = validateVariables( + variables.map((variable) => ({ key: variable.name, value: variable.value })) + ); + if (validationError) { + throw new Error(validationError); + } + const rt = data.template.runtimes.find((r) => r.name === runtime); const func = await sdk diff --git a/src/routes/(console)/project-[region]-[project]/rawVariableEditor.svelte b/src/routes/(console)/project-[region]-[project]/rawVariableEditor.svelte index cdd889992..708734444 100644 --- a/src/routes/(console)/project-[region]-[project]/rawVariableEditor.svelte +++ b/src/routes/(console)/project-[region]-[project]/rawVariableEditor.svelte @@ -6,6 +6,7 @@ import { addNotification } from '$lib/stores/notifications'; import type { Models } from '@appwrite.io/console'; import { parse } from '$lib/helpers/envfile'; + import { validateVariables } from '$lib/helpers/variables'; import { Icon, InlineCode, Layout, Tabs } from '@appwrite.io/pink-svelte'; import { InputTextarea } from '$lib/elements/forms'; import { @@ -35,7 +36,7 @@ ) => Promise; export let sdkUpdateVariable: ( variableId: string, - key: string, + key: string | undefined, value: string, secret?: boolean ) => Promise; @@ -74,10 +75,10 @@ } function validateEntries(entries: DraftVariable[]) { - for (const { key, value } of entries) { - if (value.length > 8192) { - throw new Error(`Variable ${key} is longer than 8192 allowed characters`); - } + const validationError = validateVariables(entries); + + if (validationError) { + throw new Error(validationError); } } @@ -146,22 +147,26 @@ const editableVariables = variableList.variables.filter((variable) => !variable.secret); const secretVariables = variableList.variables.filter((variable) => variable.secret); - await Promise.all( + const existingKeys = editableVariables.map((variable) => variable.key); + const existingResults = await Promise.allSettled( editableVariables.map(async (variable) => { const newValue = vars[variable.key] ?? null; if (newValue === null) { await sdkDeleteVariable(variable.$id); } else if (newValue !== variable.value) { - await sdkUpdateVariable(variable.$id, variable.key, newValue, false); + // The key is unchanged here, so leave it out and let + // the API keep the stored one. + await sdkUpdateVariable(variable.$id, undefined, newValue, false); } delete vars[variable.key]; }) ); // Add new variables, skipping keys that exist in secret variables - await Promise.all( - Object.keys(vars).map(async (key) => { + const newKeys = Object.keys(vars); + const newResults = await Promise.allSettled( + newKeys.map(async (key) => { const existingVariable = variableList.variables.find( (variable) => variable.key === key ); @@ -178,6 +183,22 @@ await sdkCreateVariable(key, vars[key], false); }) ); + + // Every variable is written on its own, so name the keys that + // failed rather than surfacing a single rejection. + const failed = [ + ...existingResults.map((result, index) => + result.status === 'rejected' ? existingKeys[index] : null + ), + ...newResults.map((result, index) => + result.status === 'rejected' ? newKeys[index] : null + ) + ].filter(Boolean); + + if (failed.length) { + throw new Error(`Failed to update variables: ${failed.join(', ')}`); + } + // Ensure secret variables are preserved variableList.variables = [ ...secretVariables, diff --git a/src/routes/(console)/project-[region]-[project]/sites/create-site/deploy/+page.svelte b/src/routes/(console)/project-[region]-[project]/sites/create-site/deploy/+page.svelte index fa75d2794..85719ebc0 100644 --- a/src/routes/(console)/project-[region]-[project]/sites/create-site/deploy/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/sites/create-site/deploy/+page.svelte @@ -28,6 +28,7 @@ import { getLatestTag } from '$lib/helpers/github'; import Link from '$lib/elements/link.svelte'; import type { FrameworkAdapterWithStartCommand } from '$lib/stores/sites'; + import { validateVariables } from '$lib/helpers/variables'; let { data @@ -147,6 +148,13 @@ $isSubmitting = true; try { + // Reject an unusable key before the resource is created, so a + // rejected variable can't leave a half-configured resource behind. + const validationError = validateVariables(variables); + if (validationError) { + throw new Error(validationError); + } + // Create site with build configuration let site = await sdk.forProject(page.params.region, page.params.project).sites.create({ siteId: id || ID.unique(), diff --git a/src/routes/(console)/project-[region]-[project]/sites/create-site/manual/+page.svelte b/src/routes/(console)/project-[region]-[project]/sites/create-site/manual/+page.svelte index f2da210d0..fd5908ab7 100644 --- a/src/routes/(console)/project-[region]-[project]/sites/create-site/manual/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/sites/create-site/manual/+page.svelte @@ -27,6 +27,7 @@ import Domain from '../domain.svelte'; import { uploader } from '$lib/stores/uploader'; import type { FrameworkAdapterWithStartCommand } from '$lib/stores/sites'; + import { validateVariables } from '$lib/helpers/variables'; export let data; let showExitModal = false; @@ -60,6 +61,13 @@ let site: Models.Site | null = null; try { + // Reject an unusable key before the resource is created, so a + // rejected variable can't leave a half-configured resource behind. + const validationError = validateVariables(variables); + if (validationError) { + throw new Error(validationError); + } + if (!domainIsValid) { addNotification({ type: 'error', diff --git a/src/routes/(console)/project-[region]-[project]/sites/create-site/repositories/repository-[repository]/+page.svelte b/src/routes/(console)/project-[region]-[project]/sites/create-site/repositories/repository-[repository]/+page.svelte index aca5fe7bb..70367fabc 100644 --- a/src/routes/(console)/project-[region]-[project]/sites/create-site/repositories/repository-[repository]/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/sites/create-site/repositories/repository-[repository]/+page.svelte @@ -27,7 +27,11 @@ import Configuration from '../../configuration.svelte'; import Domain from '../../domain.svelte'; import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store'; - import { normalizeDetectedVariables, mergeVariables } from '$lib/helpers/variables'; + import { + normalizeDetectedVariables, + mergeVariables, + validateVariables + } from '$lib/helpers/variables'; import type { FrameworkAdapterWithStartCommand } from '$lib/stores/sites'; export let data; @@ -113,6 +117,13 @@ return; } try { + // Reject an unusable key before the resource is created, so a + // rejected variable can't leave a half-configured resource behind. + const validationError = validateVariables(variables); + if (validationError) { + throw new Error(validationError); + } + const fr = Object.values(Framework).find((f) => f === framework.key); const buildRuntime = Object.values(BuildRuntime).find( (f) => f === framework.buildRuntime diff --git a/src/routes/(console)/project-[region]-[project]/sites/create-site/templates/template-[template]/+page.svelte b/src/routes/(console)/project-[region]-[project]/sites/create-site/templates/template-[template]/+page.svelte index a11121d55..006003d84 100644 --- a/src/routes/(console)/project-[region]-[project]/sites/create-site/templates/template-[template]/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/sites/create-site/templates/template-[template]/+page.svelte @@ -45,6 +45,7 @@ import { getFrameworkIcon } from '$lib/stores/sites'; import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store'; import { getTemplateSourceUrl } from '$lib/helpers/templateSource'; + import { validateVariables } from '$lib/helpers/variables'; export let data; @@ -117,6 +118,15 @@ return; } else { try { + // Reject an unusable key before the resource is created, so a + // rejected variable can't leave a half-configured resource behind. + const validationError = validateVariables( + variables.map((variable) => ({ key: variable.name, value: variable.value })) + ); + if (validationError) { + throw new Error(validationError); + } + const fr = Object.values(Framework).find((f) => f === framework.key); const buildRuntime = Object.values(BuildRuntime).find( (f) => f === framework.buildRuntime diff --git a/src/routes/(console)/project-[region]-[project]/updateVariables.svelte b/src/routes/(console)/project-[region]-[project]/updateVariables.svelte index 8b9f3da47..7164be11a 100644 --- a/src/routes/(console)/project-[region]-[project]/updateVariables.svelte +++ b/src/routes/(console)/project-[region]-[project]/updateVariables.svelte @@ -5,6 +5,7 @@ import { CardGrid, Empty, Output, PaginationInline } from '$lib/components'; import UploadVariables from './uploadVariablesModal.svelte'; import { variablesOperation, type VariablesOperationItem } from './variablesOperation'; + import { isValidVariableKey, validateVariables } from '$lib/helpers/variables'; import { goto, invalidate } from '$app/navigation'; import { Click, Submit, trackError, trackEvent } from '$lib/actions/analytics'; import { Dependencies } from '$lib/constants'; @@ -21,6 +22,7 @@ Layout, Popover, Table, + Tooltip, Alert } from '@appwrite.io/pink-svelte'; import { @@ -55,7 +57,7 @@ ) => Promise; export let sdkUpdateVariable: ( variableId: string, - key: string, + key: string | undefined, value: string, secret?: boolean ) => Promise; @@ -127,10 +129,24 @@ async function handleVariableCreated(event: CustomEvent) { const variables = event.detail; try { - const promises = variables.map((variable) => - sdkCreateVariable(variable.key, variable.value, variable?.secret || false) + const results = await Promise.allSettled( + variables.map((variable) => + sdkCreateVariable(variable.key, variable.value, variable?.secret || false) + ) ); - await Promise.all(promises); + + // Each variable is created on its own, so name the keys that failed + // instead of reporting a single rejection for the whole batch. + const failed = results + .map((result, index) => + result.status === 'rejected' ? variables[index].key : null + ) + .filter(Boolean); + + if (failed.length) { + throw new Error(`Failed to create variables: ${failed.join(', ')}`); + } + fullVariableList = undefined; showVariablesModal = false; addNotification({ @@ -174,7 +190,10 @@ async function handleVariableSecret(event: CustomEvent) { const variable = event.detail; try { - await sdkUpdateVariable(variable.$id, variable.key, variable.value, variable.secret); + // Marking a variable secret never changes its key, so leave the key + // out and keep the stored one — including keys that predate the + // identifier rule. + await sdkUpdateVariable(variable.$id, undefined, variable.value, variable.secret); fullVariableList = undefined; selectedVar = null; showVariablesModal = false; @@ -237,6 +256,14 @@ async function handleVariablePromoted(variable: Models.Variable) { try { + // Promoting a conflicting key deletes the existing global variable + // before recreating it, so refuse a key the API would reject rather + // than deleting one and failing to create its replacement. + const validationError = validateVariables([variable]); + if (validationError) { + throw new Error(validationError); + } + const globalVariable = globalVariableList ? globalVariableList.variables.find( (globalVariable) => globalVariable.key === variable.key @@ -507,6 +534,19 @@ class="icon-exclamation u-color-text-warning" aria-hidden="true"> {/if} + {#if !isValidVariableKey(variable.key)} + + + + This key can't be used as an environment variable + name, so it is ignored at build and runtime. Rename + it using only letters, digits and underscores, + without starting with a digit. + + + {/if} {variable.key} diff --git a/src/routes/(console)/project-[region]-[project]/updateVariablesModal.svelte b/src/routes/(console)/project-[region]-[project]/updateVariablesModal.svelte index d22a14c57..af61ff9fa 100644 --- a/src/routes/(console)/project-[region]-[project]/updateVariablesModal.svelte +++ b/src/routes/(console)/project-[region]-[project]/updateVariablesModal.svelte @@ -8,6 +8,7 @@ import { base } from '$app/paths'; import { Alert, Layout, Selector } from '@appwrite.io/pink-svelte'; import { Link } from '$lib/elements'; + import { getVariableValueError, validateVariables } from '$lib/helpers/variables'; export let isGlobal: boolean; export let product: 'function' | 'site' = 'function'; @@ -21,6 +22,10 @@ secret: selectedVar?.secret }; + const originalKey = selectedVar?.key; + + let error = ''; + const dispatch = createEventDispatcher(); function close() { @@ -29,7 +34,21 @@ } function handleVariable() { - dispatch('updated', pair); + const keyChanged = pair.key !== originalKey; + + // A key stored before the identifier rule existed is left untouched so + // its value stays editable; only a key the user actually changed has to + // satisfy the rule. + const validationError = keyChanged + ? validateVariables([pair]) + : getVariableValueError(pair.key, pair.value); + + if (validationError) { + error = validationError; + return; + } + + dispatch('updated', { ...pair, key: keyChanged ? pair.key : undefined }); close(); } @@ -41,6 +60,7 @@ diff --git a/src/routes/(console)/project-[region]-[project]/uploadVariablesModal.svelte b/src/routes/(console)/project-[region]-[project]/uploadVariablesModal.svelte index 134fe5c09..e2d10734c 100644 --- a/src/routes/(console)/project-[region]-[project]/uploadVariablesModal.svelte +++ b/src/routes/(console)/project-[region]-[project]/uploadVariablesModal.svelte @@ -16,6 +16,7 @@ } from '@appwrite.io/pink-svelte'; import { parse } from '$lib/helpers/envfile'; import { removeFile } from '$lib/helpers/files'; + import { validateVariables } from '$lib/helpers/variables'; import type { VariablesOperationItem } from './variablesOperation'; export let show = false; @@ -27,7 +28,7 @@ ) => Promise; export let sdkUpdateVariable: ( variableId: string, - key: string, + key: string | undefined, value: string, secret?: boolean ) => Promise; @@ -64,18 +65,19 @@ const entries = Object.entries(uploaded); - for (const [key, value] of entries) { - if (value.length > 8192) { - throw new Error(`Variable ${key} is longer than 8192 allowed characters`); - } - } - const filteredEntries = entries.filter(([, value]) => !!value); if (!filteredEntries.length) { throw new Error('No variables found'); } + const validationError = validateVariables( + filteredEntries.map(([key, value]) => ({ key, value })) + ); + if (validationError) { + throw new Error(validationError); + } + if (filteredEntries.length > 100) { throw new Error('Please upload a file with fewer than 100 environment variables.'); } @@ -93,7 +95,7 @@ show = false; - await Promise.all( + const results = await Promise.allSettled( filteredEntries.map(([key, value]) => { const found = variableList.variables.find((variable) => variable.key === key); return found @@ -102,6 +104,18 @@ }) ); + // Each variable is written on its own, so report which keys failed + // instead of letting one rejection hide the ones that landed. + const failed = results + .map((result, index) => + result.status === 'rejected' ? filteredEntries[index][0] : null + ) + .filter(Boolean); + + if (failed.length) { + throw new Error(`Failed to upload variables: ${failed.join(', ')}`); + } + onStatusChange({ id: importId, count: uploadCount, From 0feeb2a627a16e577f3f252d32e6625457da9490 Mon Sep 17 00:00:00 2001 From: Levi van Noort <73097785+levivannoort@users.noreply.github.com> Date: Wed, 12 Aug 2026 12:28:58 +0200 Subject: [PATCH 07/22] fix(variables): drop the key from the draft map before writing it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A rejected update left its key in vars, so the second pass picked it up as a new variable and resent the stored key — the exact call the sparse update is meant to avoid for keys that predate the identifier rule. --- .../project-[region]-[project]/rawVariableEditor.svelte | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/routes/(console)/project-[region]-[project]/rawVariableEditor.svelte b/src/routes/(console)/project-[region]-[project]/rawVariableEditor.svelte index 708734444..b1c3b79b2 100644 --- a/src/routes/(console)/project-[region]-[project]/rawVariableEditor.svelte +++ b/src/routes/(console)/project-[region]-[project]/rawVariableEditor.svelte @@ -152,6 +152,11 @@ editableVariables.map(async (variable) => { const newValue = vars[variable.key] ?? null; + // Claim the key up front. A rejected write must not leave it + // behind for the second pass, which would retry it as a new + // variable and send the stored key along with it. + delete vars[variable.key]; + if (newValue === null) { await sdkDeleteVariable(variable.$id); } else if (newValue !== variable.value) { @@ -159,7 +164,6 @@ // the API keep the stored one. await sdkUpdateVariable(variable.$id, undefined, newValue, false); } - delete vars[variable.key]; }) ); From 40a286f6e0b1fa4757a1fdf51c0cb2703b91102f Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Wed, 12 Aug 2026 23:55:44 +0530 Subject: [PATCH 08/22] fix(sites): keep framework start commands out of the console The create-site flows read startCommand off a framework adapter and offered it as a prefilled value and a placeholder. The API never returns that field - FrameworkAdapter does not declare it - so the reads always resolved to undefined, and the cast that made them typecheck was the only thing hiding it. Had the field ever been returned, the console would have put an internal runtime command in front of every user creating a site. Drop the field from the create flows entirely and let the server pick its own default. In site settings the input stays, but it moves under a collapsed Advanced section, loses the Reset-to-default button that had nothing to reset to, and takes a generic placeholder. --- src/lib/stores/sites.ts | 6 -- .../sites/create-site/configuration.svelte | 29 ++------ .../sites/create-site/deploy/+page.svelte | 19 +---- .../sites/create-site/manual/+page.svelte | 6 +- .../repository-[repository]/+page.svelte | 9 +-- .../settings/updateBuildSettings.svelte | 71 +++++++++---------- 6 files changed, 42 insertions(+), 98 deletions(-) diff --git a/src/lib/stores/sites.ts b/src/lib/stores/sites.ts index ef39511ee..29d811332 100644 --- a/src/lib/stores/sites.ts +++ b/src/lib/stores/sites.ts @@ -1,9 +1,3 @@ -import type { Models } from '@appwrite.io/console'; - -export type FrameworkAdapterWithStartCommand = Models.FrameworkAdapter & { - startCommand?: string; -}; - export function getFrameworkIcon(framework: string) { switch (true) { case framework.toLocaleLowerCase().includes('sveltekit'): diff --git a/src/routes/(console)/project-[region]-[project]/sites/create-site/configuration.svelte b/src/routes/(console)/project-[region]-[project]/sites/create-site/configuration.svelte index f6d8129d6..8ab02601a 100644 --- a/src/routes/(console)/project-[region]-[project]/sites/create-site/configuration.svelte +++ b/src/routes/(console)/project-[region]-[project]/sites/create-site/configuration.svelte @@ -3,22 +3,20 @@ import { Fieldset, Layout, Accordion } from '@appwrite.io/pink-svelte'; import type { Models } from '@appwrite.io/console'; import { iconPath } from '$lib/stores/app'; - import { getFrameworkIcon, type FrameworkAdapterWithStartCommand } from '$lib/stores/sites'; + import { getFrameworkIcon } from '$lib/stores/sites'; import { EnvironmentVariables } from '$lib/components/variables'; export let frameworks: Models.Framework[]; export let selectedFramework: Models.Framework; $: frameworkData = frameworks.find((framework) => framework.key === selectedFramework?.key); - $: adapterData = (frameworkData?.adapters.find((adapter) => adapter.key === 'ssr') ?? - frameworkData?.adapters.find( - (adapter) => adapter.key === 'static' - )) as FrameworkAdapterWithStartCommand; + $: adapterData = + frameworkData?.adapters.find((adapter) => adapter.key === 'ssr') ?? + frameworkData?.adapters.find((adapter) => adapter.key === 'static'); export let variables: Partial[] = []; export let isLoading = false; export let installCommand = ''; export let buildCommand = ''; - export let startCommand = ''; export let outputDirectory = ''; let frameworkId = selectedFramework.key; @@ -28,7 +26,6 @@ $: if (frameworkData && adapterDefaultsKey !== lastAdapterDefaultsKey) { installCommand = adapterData?.installCommand ?? ''; buildCommand = adapterData?.buildCommand ?? ''; - startCommand = adapterData?.startCommand ?? ''; outputDirectory = adapterData?.outputDirectory ?? ''; lastAdapterDefaultsKey = adapterDefaultsKey; } @@ -86,24 +83,6 @@ Reset - {#if adapterData?.key === 'ssr'} - - - - - {/if} data.frameworks.frameworks.find((f) => f.key === framework)?.adapters?.[0] - ); - const shouldShowStartCommand = $derived(primaryAdapter?.key === Adapter.Ssr); - $effect(() => { if (framework && data.frameworks && !hasCustomCommands) { const fw = data.frameworks.frameworks.find((f) => f.key === framework); @@ -94,7 +87,6 @@ const adapter = fw.adapters[0]; installCommand = adapter.installCommand || ''; buildCommand = adapter.buildCommand || ''; - startCommand = (adapter as FrameworkAdapterWithStartCommand).startCommand || ''; outputDirectory = adapter.outputDirectory || ''; } } @@ -111,11 +103,10 @@ // Build configuration - use from URL params or defaults installCommand = page.url.searchParams.get('install') || ''; buildCommand = page.url.searchParams.get('build') || ''; - startCommand = page.url.searchParams.get('start') || ''; outputDirectory = page.url.searchParams.get('output') || ''; // Check if custom commands were provided via URL - hasCustomCommands = !!(installCommand || buildCommand || startCommand || outputDirectory); + hasCustomCommands = !!(installCommand || buildCommand || outputDirectory); // If no custom commands, auto-fill from framework defaults if (!hasCustomCommands && data.frameworks) { @@ -124,7 +115,6 @@ const adapter = fw.adapters[0]; installCommand = adapter.installCommand || ''; buildCommand = adapter.buildCommand || ''; - startCommand = (adapter as FrameworkAdapterWithStartCommand).startCommand || ''; outputDirectory = adapter.outputDirectory || ''; } } @@ -155,7 +145,6 @@ buildRuntime: selectedFramework.buildRuntime, installCommand: installCommand || undefined, buildCommand: buildCommand || undefined, - startCommand: shouldShowStartCommand ? startCommand || undefined : undefined, outputDirectory: outputDirectory || undefined, adapter: framework === Framework.Other ? Adapter.Static : undefined, providerSilentMode: false @@ -284,12 +273,6 @@ label="Build command" placeholder={buildCommand || 'npm run build'} bind:value={buildCommand} /> - {#if shouldShowStartCommand} - - {/if} f.key === 'other') ?? data.frameworks.frameworks?.[0]; - let adapter = framework?.adapters[0] as FrameworkAdapterWithStartCommand; + let adapter = framework?.adapters[0]; let installCommand = adapter?.installCommand; let buildCommand = adapter?.buildCommand; - let startCommand = adapter?.startCommand; let outputDirectory = adapter?.outputDirectory; let variables: Partial[] = []; let files: FileList; @@ -79,7 +77,6 @@ buildRuntime, installCommand: installCommand || undefined, buildCommand: buildCommand || undefined, - startCommand: startCommand || undefined, outputDirectory: outputDirectory || undefined }); @@ -254,7 +251,6 @@ f.key === 'other'); - let adapter = framework?.adapters[0] as FrameworkAdapterWithStartCommand; + let adapter = framework?.adapters[0]; let branch: string; let rootDir = './'; let installCommand = adapter?.installCommand; let buildCommand = adapter?.buildCommand; - let startCommand = adapter?.startCommand; let outputDirectory = adapter?.outputDirectory; let variables: Partial[] = []; let silentMode = false; @@ -83,10 +81,9 @@ if (!framework) { framework = data.frameworks.frameworks.find((f) => f.key === 'other'); } - adapter = framework?.adapters[0] as FrameworkAdapterWithStartCommand; + adapter = framework?.adapters[0]; installCommand = adapter?.installCommand; buildCommand = adapter?.buildCommand; - startCommand = adapter?.startCommand; outputDirectory = adapter?.outputDirectory; const detectedVariables = normalizeDetectedVariables(response?.variables); if (detectedVariables.length) { @@ -124,7 +121,6 @@ buildRuntime, installCommand: installCommand || undefined, buildCommand: buildCommand || undefined, - startCommand: startCommand || undefined, outputDirectory: outputDirectory || undefined, installationId: data.installation.$id, providerRepositoryId: data.repository.id, @@ -223,7 +219,6 @@ a.key === adapter) ?? - selectedFramework.adapters[0]) as FrameworkAdapterWithStartCommand + let frameworkAdapterData = $derived( + selectedFramework.adapters.find((a) => a.key === adapter) ?? selectedFramework.adapters[0] ); $effect(() => { @@ -77,17 +84,18 @@ } //Update values - const data = (selectedFramework.adapters.find((a) => a.key === adapter) ?? - selectedFramework.adapters[0]) as FrameworkAdapterWithStartCommand; + const data = + selectedFramework.adapters.find((a) => a.key === adapter) ?? + selectedFramework.adapters[0]; installCommand = data.installCommand; buildCommand = data.buildCommand; - startCommand = data.startCommand; outputDirectory = data.outputDirectory; adapter = data.key as Adapter; fallback = data.fallbackFile; } else if (hasFrameworkSelectionChanged) { - const data = (selectedFramework.adapters.find((a) => a.key === adapter) ?? - selectedFramework.adapters[0]) as FrameworkAdapterWithStartCommand; + const data = + selectedFramework.adapters.find((a) => a.key === adapter) ?? + selectedFramework.adapters[0]; const isOriginalAdapter = adapter === site.adapter; installCommand = isOriginalAdapter @@ -96,9 +104,6 @@ buildCommand = isOriginalAdapter ? (site?.buildCommand ?? frameworkAdapterData.buildCommand) : data.buildCommand; - startCommand = isOriginalAdapter - ? (site?.startCommand ?? frameworkAdapterData.startCommand) - : data.startCommand; outputDirectory = isOriginalAdapter ? (site?.outputDirectory ?? frameworkAdapterData.outputDirectory) : data.outputDirectory; @@ -193,17 +198,13 @@ } } - function reset(type: 'installCommand' | 'buildCommand' | 'startCommand' | 'outputDirectory') { - const data = selectedFramework.adapters.find( - (a) => a.key === adapter - ) as FrameworkAdapterWithStartCommand; + function reset(type: 'installCommand' | 'buildCommand' | 'outputDirectory') { + const data = selectedFramework.adapters.find((a) => a.key === adapter); if (type === 'installCommand') { installCommand = data.installCommand; } else if (type === 'buildCommand') { buildCommand = data.buildCommand; - } else if (type === 'startCommand') { - startCommand = data.startCommand; } else if (type === 'outputDirectory') { outputDirectory = data.outputDirectory; } @@ -332,24 +333,6 @@ Reset - {#if adapter === Adapter.Ssr} - - - - - {/if} {/if} + {#if adapter === Adapter.Ssr} + + + Leave empty to let your framework start the way Appwrite + expects. Set a command only if your site needs its own + entrypoint. + + + + {/if} From 6e64d0ce57b5063c29f3af91ffb17ce12c02f18c Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Thu, 13 Aug 2026 00:54:31 +0530 Subject: [PATCH 09/22] Match the start command copy used by the new console --- .../sites/site-[site]/settings/updateBuildSettings.svelte | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/routes/(console)/project-[region]-[project]/sites/site-[site]/settings/updateBuildSettings.svelte b/src/routes/(console)/project-[region]-[project]/sites/site-[site]/settings/updateBuildSettings.svelte index 890bb9518..feba962b5 100644 --- a/src/routes/(console)/project-[region]-[project]/sites/site-[site]/settings/updateBuildSettings.svelte +++ b/src/routes/(console)/project-[region]-[project]/sites/site-[site]/settings/updateBuildSettings.svelte @@ -367,9 +367,8 @@ {#if adapter === Adapter.Ssr} - Leave empty to let your framework start the way Appwrite - expects. Set a command only if your site needs its own - entrypoint. + Command used to start your SSR server after a successful deploy. + Leave it empty to use the framework default. Date: Thu, 13 Aug 2026 11:20:18 +0530 Subject: [PATCH 10/22] Clear the start command when the framework or adapter changes A start command names an entrypoint belonging to one framework. Carrying it across a switch submits it against a runtime that has no such entrypoint, and a switch to static leaves a command the form no longer shows. Reset it alongside the other framework-derived fields, and send it only for the ssr adapter, matching the fallbackFile line beside it. --- .../sites/site-[site]/settings/updateBuildSettings.svelte | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/routes/(console)/project-[region]-[project]/sites/site-[site]/settings/updateBuildSettings.svelte b/src/routes/(console)/project-[region]-[project]/sites/site-[site]/settings/updateBuildSettings.svelte index feba962b5..527fae963 100644 --- a/src/routes/(console)/project-[region]-[project]/sites/site-[site]/settings/updateBuildSettings.svelte +++ b/src/routes/(console)/project-[region]-[project]/sites/site-[site]/settings/updateBuildSettings.svelte @@ -92,6 +92,7 @@ outputDirectory = data.outputDirectory; adapter = data.key as Adapter; fallback = data.fallbackFile; + startCommand = ''; } else if (hasFrameworkSelectionChanged) { const data = selectedFramework.adapters.find((a) => a.key === adapter) ?? @@ -110,6 +111,7 @@ fallback = isOriginalAdapter ? (site?.fallbackFile ?? data.fallbackFile) : data.fallbackFile; + startCommand = isOriginalAdapter ? (site?.startCommand ?? '') : ''; } lastFrameworkAdapterKey = `${selectedFramework.key}:${adapter ?? ''}`; @@ -167,7 +169,7 @@ timeout: site.timeout || undefined, installCommand: installCommand || undefined, buildCommand: buildCommand || undefined, - startCommand: startCommand || undefined, + startCommand: adptr?.key === 'ssr' ? startCommand || undefined : undefined, outputDirectory: outputDirectory || undefined, buildRuntime: (site?.buildRuntime as BuildRuntime) || undefined, adapter: (adptr?.key as Adapter) || undefined, From e10ae018bf204e1c25fb2d700333b136dd1dac20 Mon Sep 17 00:00:00 2001 From: Levi van Noort <73097785+levivannoort@users.noreply.github.com> Date: Thu, 13 Aug 2026 08:50:46 +0200 Subject: [PATCH 11/22] fix(variables): filter valueless entries before validating an import An entry with an empty value is discarded rather than written, so an invalid key on one of them was rejecting the whole file and taking the valid variables down with it. --- .../components/variables/importVariablesModal.svelte | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/components/variables/importVariablesModal.svelte b/src/lib/components/variables/importVariablesModal.svelte index 8ff09d62a..9eed108b2 100644 --- a/src/lib/components/variables/importVariablesModal.svelte +++ b/src/lib/components/variables/importVariablesModal.svelte @@ -36,7 +36,9 @@ if (!Object.keys(uploaded).length) { throw new Error('No variables found'); } - const entries = Object.entries(uploaded); + // Drop the valueless entries first. They are never written, so an + // invalid key on one of them must not reject the whole file. + const entries = Object.entries(uploaded).filter(([, value]) => !!value); const validationError = validateVariables( entries.map(([key, value]) => ({ key, value })) @@ -45,11 +47,9 @@ throw new Error(validationError); } - entries - .filter(([, value]) => !!value) - .forEach(([key, value]) => { - variables.push({ key, value, secret }); - }); + entries.forEach(([key, value]) => { + variables.push({ key, value, secret }); + }); show = false; } catch (e) { From 40588237edd8046cd98c737fb0ce830894d407a2 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Thu, 13 Aug 2026 16:16:05 +0530 Subject: [PATCH 12/22] Keep the start command field, drop the adapter reads behind it The field stays where it is. What goes is the code reading startCommand off a framework adapter: the SDK never declared it and the API no longer sends it, so the prefill and the placeholder were pointing at nothing, and Reset restored a value that does not exist. Also stop carrying a start command across a framework or adapter change - it names an entrypoint only the previous framework has - and send it only for the ssr adapter, matching the fallbackFile line beside it. --- .../sites/create-site/configuration.svelte | 10 ++++++ .../sites/create-site/deploy/+page.svelte | 16 ++++++++- .../sites/create-site/manual/+page.svelte | 3 ++ .../repository-[repository]/+page.svelte | 3 ++ .../settings/updateBuildSettings.svelte | 36 +++++++------------ 5 files changed, 43 insertions(+), 25 deletions(-) diff --git a/src/routes/(console)/project-[region]-[project]/sites/create-site/configuration.svelte b/src/routes/(console)/project-[region]-[project]/sites/create-site/configuration.svelte index 8ab02601a..f92ec6ae0 100644 --- a/src/routes/(console)/project-[region]-[project]/sites/create-site/configuration.svelte +++ b/src/routes/(console)/project-[region]-[project]/sites/create-site/configuration.svelte @@ -17,6 +17,7 @@ export let isLoading = false; export let installCommand = ''; export let buildCommand = ''; + export let startCommand = ''; export let outputDirectory = ''; let frameworkId = selectedFramework.key; @@ -83,6 +84,15 @@ Reset + {#if adapterData?.key === 'ssr'} + + + + {/if} data.frameworks.frameworks.find((f) => f.key === framework)?.adapters?.[0] + ); + const shouldShowStartCommand = $derived(primaryAdapter?.key === Adapter.Ssr); + $effect(() => { if (framework && data.frameworks && !hasCustomCommands) { const fw = data.frameworks.frameworks.find((f) => f.key === framework); @@ -103,10 +109,11 @@ // Build configuration - use from URL params or defaults installCommand = page.url.searchParams.get('install') || ''; buildCommand = page.url.searchParams.get('build') || ''; + startCommand = page.url.searchParams.get('start') || ''; outputDirectory = page.url.searchParams.get('output') || ''; // Check if custom commands were provided via URL - hasCustomCommands = !!(installCommand || buildCommand || outputDirectory); + hasCustomCommands = !!(installCommand || buildCommand || startCommand || outputDirectory); // If no custom commands, auto-fill from framework defaults if (!hasCustomCommands && data.frameworks) { @@ -145,6 +152,7 @@ buildRuntime: selectedFramework.buildRuntime, installCommand: installCommand || undefined, buildCommand: buildCommand || undefined, + startCommand: shouldShowStartCommand ? startCommand || undefined : undefined, outputDirectory: outputDirectory || undefined, adapter: framework === Framework.Other ? Adapter.Static : undefined, providerSilentMode: false @@ -273,6 +281,12 @@ label="Build command" placeholder={buildCommand || 'npm run build'} bind:value={buildCommand} /> + {#if shouldShowStartCommand} + + {/if} [] = []; let files: FileList; @@ -77,6 +78,7 @@ buildRuntime, installCommand: installCommand || undefined, buildCommand: buildCommand || undefined, + startCommand: startCommand || undefined, outputDirectory: outputDirectory || undefined }); @@ -251,6 +253,7 @@ [] = []; let silentMode = false; @@ -121,6 +122,7 @@ buildRuntime, installCommand: installCommand || undefined, buildCommand: buildCommand || undefined, + startCommand: startCommand || undefined, outputDirectory: outputDirectory || undefined, installationId: data.installation.$id, providerRepositoryId: data.repository.id, @@ -219,6 +221,7 @@ a.key === adapter) ?? @@ -105,13 +97,13 @@ buildCommand = isOriginalAdapter ? (site?.buildCommand ?? frameworkAdapterData.buildCommand) : data.buildCommand; + startCommand = isOriginalAdapter ? (site?.startCommand ?? '') : ''; outputDirectory = isOriginalAdapter ? (site?.outputDirectory ?? frameworkAdapterData.outputDirectory) : data.outputDirectory; fallback = isOriginalAdapter ? (site?.fallbackFile ?? data.fallbackFile) : data.fallbackFile; - startCommand = isOriginalAdapter ? (site?.startCommand ?? '') : ''; } lastFrameworkAdapterKey = `${selectedFramework.key}:${adapter ?? ''}`; @@ -335,6 +327,15 @@ Reset + {#if adapter === Adapter.Ssr} + + + + {/if} {/if} - {#if adapter === Adapter.Ssr} - - - Command used to start your SSR server after a successful deploy. - Leave it empty to use the framework default. - - - - {/if} From a175d022e2c54b1e08be65a08733ddaf4fe83a42 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Thu, 13 Aug 2026 17:19:13 +0530 Subject: [PATCH 13/22] Clear the start command when the framework changes on create too The settings form already resets it; the create flows kept the previous framework's entrypoint in state and submitted it, and kept sending it after a switch to a framework that only builds static. Reset it alongside the other adapter-derived fields in both places. --- .../sites/create-site/configuration.svelte | 1 + .../sites/create-site/deploy/+page.svelte | 1 + 2 files changed, 2 insertions(+) diff --git a/src/routes/(console)/project-[region]-[project]/sites/create-site/configuration.svelte b/src/routes/(console)/project-[region]-[project]/sites/create-site/configuration.svelte index f92ec6ae0..73e1eea7c 100644 --- a/src/routes/(console)/project-[region]-[project]/sites/create-site/configuration.svelte +++ b/src/routes/(console)/project-[region]-[project]/sites/create-site/configuration.svelte @@ -28,6 +28,7 @@ installCommand = adapterData?.installCommand ?? ''; buildCommand = adapterData?.buildCommand ?? ''; outputDirectory = adapterData?.outputDirectory ?? ''; + startCommand = ''; lastAdapterDefaultsKey = adapterDefaultsKey; } diff --git a/src/routes/(console)/project-[region]-[project]/sites/create-site/deploy/+page.svelte b/src/routes/(console)/project-[region]-[project]/sites/create-site/deploy/+page.svelte index 13829d76f..42890ed97 100644 --- a/src/routes/(console)/project-[region]-[project]/sites/create-site/deploy/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/sites/create-site/deploy/+page.svelte @@ -94,6 +94,7 @@ installCommand = adapter.installCommand || ''; buildCommand = adapter.buildCommand || ''; outputDirectory = adapter.outputDirectory || ''; + startCommand = ''; } } }); From 58b37773f3f63248c31edc72ef4710e76dce7d74 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Fri, 14 Aug 2026 11:17:34 +0530 Subject: [PATCH 14/22] Reset the start command from the framework select, not the effect The effect is skipped whenever the URL supplied any command, so a deploy link carrying ?start= kept that entrypoint through a framework switch. Resetting inside the effect could not fix it either: the effect also runs on load, where the URL value has to survive. Move the reset onto the select, so only a user changing framework clears it and the link keeps working as written. --- .../sites/create-site/deploy/+page.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/(console)/project-[region]-[project]/sites/create-site/deploy/+page.svelte b/src/routes/(console)/project-[region]-[project]/sites/create-site/deploy/+page.svelte index 42890ed97..ff9e5368d 100644 --- a/src/routes/(console)/project-[region]-[project]/sites/create-site/deploy/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/sites/create-site/deploy/+page.svelte @@ -94,7 +94,6 @@ installCommand = adapter.installCommand || ''; buildCommand = adapter.buildCommand || ''; outputDirectory = adapter.outputDirectory || ''; - startCommand = ''; } } }); @@ -262,7 +261,8 @@ label="Framework" placeholder="Select framework" bind:value={framework} - options={frameworkSelectOptions} /> + options={frameworkSelectOptions} + on:change={() => (startCommand = '')} /> From 6fa8402cd0375be30ac59d2455a804bc54b68dd4 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Fri, 14 Aug 2026 11:24:14 +0530 Subject: [PATCH 15/22] Pin nanoid past the indefinite-loop advisory bun audit fails on GHSA-2v37-7h3g-55p8: the lockfile pinned nanoid 3.3.17 under postcss and @ai-sdk/provider-utils, and neither `bun update nanoid` nor updating those parents re-resolved it. Bun ignores npm's nested override syntax, so the override has to be flat. That takes the direct dependency to the 3.x line as well. The only use is nanoid/non-secure, which 3.x provides, and the declared range now matches what installs rather than claiming a 5.x that the override replaces. --- bun.lock | 17 ++++++----------- package.json | 5 +++-- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/bun.lock b/bun.lock index eed9e9aa4..d199d20a8 100644 --- a/bun.lock +++ b/bun.lock @@ -37,7 +37,7 @@ "flatted": "^3.4.2", "ignore": "^6.0.2", "json5": "^2.2.3", - "nanoid": "^5.1.16", + "nanoid": "^3.3.18", "nanotar": "^0.3.0", "pretty-bytes": "^6.1.1", "remarkable": "^2.0.1", @@ -97,6 +97,7 @@ "immutable": "^5.1.8", "js-yaml": "^4.3.1", "minimatch": "10.2.3", + "nanoid": "^3.3.18", "picomatch": "^4.0.4", "postcss": "^8.5.18", "vite": "npm:rolldown-vite@latest", @@ -130,15 +131,15 @@ "@analytics/type-utils": ["@analytics/type-utils@0.6.4", "", {}, "sha512-Ou1gQxFakOWLcPnbFVsrPb8g1wLLUZYYJXDPjHkG07+5mustGs5yqACx42UAu4A6NszNN6Z5gGxhyH45zPWRxw=="], - "@appwrite.io/console": ["@appwrite.io/console@https://pkg.vc/-/@appwrite/@appwrite.io/console@6be9e62", { "dependencies": { "json-bigint": "1.0.0" } }, "sha512-XvEyYAb9HtcySeLgn5ZxVCEBhzxSCXfQurcSVp6Wnj1amBFx5CWsKhfWHelG9DxFG9SkeHmY+bTcZneOAhgBkw=="], + "@appwrite.io/console": ["@appwrite.io/console@https://pkg.vc/-/@appwrite/@appwrite.io/console@6be9e62", { "dependencies": { "json-bigint": "1.0.0" } }], "@appwrite.io/pink-icons": ["@appwrite.io/pink-icons@0.25.0", "", {}, "sha512-0O3i2oEuh5mWvjO80i+X6rbzrWLJ1m5wmv2/M3a1p2PyBJsFxN8xQMTEmTn3Wl/D26SsM7SpzbdW6gmfgoVU9Q=="], - "@appwrite.io/pink-icons-svelte": ["@appwrite.io/pink-icons-svelte@https://pkg.vc/-/@appwrite/@appwrite.io/pink-icons-svelte@bfe7ce3", { "peerDependencies": { "svelte": "^4.0.0" } }, "sha512-2HYl/CC2OlfZIR7LzbLXuSPBn0iNkjbnxpaeGCkZ7UNZ/hFeSeeWjDJqTBMdZ8+X95uuZqHx62XPTiE/svuSXQ=="], + "@appwrite.io/pink-icons-svelte": ["@appwrite.io/pink-icons-svelte@https://pkg.vc/-/@appwrite/@appwrite.io/pink-icons-svelte@bfe7ce3", { "peerDependencies": { "svelte": "^4.0.0" } }], "@appwrite.io/pink-legacy": ["@appwrite.io/pink-legacy@1.0.3", "", { "dependencies": { "@appwrite.io/pink-icons": "1.0.0", "the-new-css-reset": "^1.11.2" } }, "sha512-GGde5fmPhs+s6/3aFeMPc/kKADG/gTFkYQSy6oBN8pK0y0XNCLrZZgBv+EBbdhwdtqVEWXa0X85Mv9w7jcIlwQ=="], - "@appwrite.io/pink-svelte": ["@appwrite.io/pink-svelte@https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@8dcaa17", { "dependencies": { "@appwrite.io/pink-icons-svelte": "2.0.0-RC.1", "@floating-ui/dom": "^1.6.13", "@melt-ui/pp": "^0.3.2", "@melt-ui/svelte": "^0.86.6", "@tanstack/svelte-virtual": "^3.13.10", "ansicolor": "^2.0.3", "d3": "^7.9.0", "fuse.js": "^7.1.0", "pretty-bytes": "^6.1.1", "shiki": "^1.18.0", "svelte-motion": "^0.12.2", "svelte-sonner": "^0.3.28" }, "peerDependencies": { "svelte": "^4.0.0" } }, "sha512-rw3zXN7/cUciCnhj0FR8M0H5Db+LYYMaKtPxvOAIMxNTBmStzU8kTw6grqIvdtFu9vybIsjKtIwm9QLHpNDBjA=="], + "@appwrite.io/pink-svelte": ["@appwrite.io/pink-svelte@https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@8dcaa17", { "dependencies": { "@appwrite.io/pink-icons-svelte": "2.0.0-RC.1", "@floating-ui/dom": "^1.6.13", "@melt-ui/pp": "^0.3.2", "@melt-ui/svelte": "^0.86.6", "@tanstack/svelte-virtual": "^3.13.10", "ansicolor": "^2.0.3", "d3": "^7.9.0", "fuse.js": "^7.1.0", "pretty-bytes": "^6.1.1", "shiki": "^1.18.0", "svelte-motion": "^0.12.2", "svelte-sonner": "^0.3.28" }, "peerDependencies": { "svelte": "^4.0.0" } }], "@asamuzakjp/css-color": ["@asamuzakjp/css-color@3.2.0", "", { "dependencies": { "@csstools/css-calc": "^2.1.3", "@csstools/css-color-parser": "^3.0.9", "@csstools/css-parser-algorithms": "^3.0.4", "@csstools/css-tokenizer": "^3.0.3", "lru-cache": "^10.4.3" } }, "sha512-K1A6z8tS3XsmCMM86xoWdn7Fkdn9m6RSVtocUrJYIwZnFVkng/PvkEoWtOWmP+Scc6saYWHWZYbndEEXxl24jw=="], @@ -1128,7 +1129,7 @@ "ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="], - "nanoid": ["nanoid@5.1.16", "", { "bin": { "nanoid": "bin/nanoid.js" } }, "sha512-kVrnsrJqMR8+oLJnGEmSWw9BivK5mt7H3FZatVRjrc5wGqFYuBxX1yG7+A7Gi5AefkX6t/oCkizcQgpu0cY1dQ=="], + "nanoid": ["nanoid@3.3.18", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w=="], "nanotar": ["nanotar@0.3.0", "", {}, "sha512-Kv2JYYiCzt16Kt5QwAc9BFG89xfPNBx+oQL4GQXD9nLqPkZBiNaqaCWtwnbk/q7UVsTYevvM1b0UF8zmEI4pCg=="], @@ -1500,8 +1501,6 @@ "@ai-sdk/provider-utils/@ai-sdk/provider": ["@ai-sdk/provider@1.0.11", "", { "dependencies": { "json-schema": "^0.4.0" } }, "sha512-CPyImHGiT3svyfmvPvAFTianZzWFtm0qK82XjwlQIA1C3IQ2iku/PMQXi7aFyrX0TyMh3VTkJPB03tjU2VXVrw=="], - "@ai-sdk/provider-utils/nanoid": ["nanoid@3.3.17", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-xQLf0A3HOMlgHq0n247/LRuAOYmB7dXJ/DvAxGvsSBij45XtBSmQycu+F8ODbHwns/XyFZagyL1+J0Offw1E0g=="], - "@ai-sdk/ui-utils/@ai-sdk/provider": ["@ai-sdk/provider@1.0.11", "", { "dependencies": { "json-schema": "^0.4.0" } }, "sha512-CPyImHGiT3svyfmvPvAFTianZzWFtm0qK82XjwlQIA1C3IQ2iku/PMQXi7aFyrX0TyMh3VTkJPB03tjU2VXVrw=="], "@appwrite.io/pink-legacy/@appwrite.io/pink-icons": ["@appwrite.io/pink-icons@1.0.0", "", {}, "sha512-+zpksP07MvOYwhx9AZDFW0pxXQNC2juKwyOQVRAwAOkN1ACSQKPlyytkI1u2ci6CQPWjJe20CzbvBBuRNXOKjA=="], @@ -1524,8 +1523,6 @@ "@eslint/eslintrc/ignore": ["ignore@5.3.2", "", {}, "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g=="], - "@melt-ui/svelte/nanoid": ["nanoid@5.1.16", "", { "bin": { "nanoid": "bin/nanoid.js" } }, "sha512-kVrnsrJqMR8+oLJnGEmSWw9BivK5mt7H3FZatVRjrc5wGqFYuBxX1yG7+A7Gi5AefkX6t/oCkizcQgpu0cY1dQ=="], - "@opentelemetry/core/@opentelemetry/semantic-conventions": ["@opentelemetry/semantic-conventions@1.28.0", "", {}, "sha512-lp4qAiMTD4sNWW4DbKLBkfiMZ4jbAboJIGOQr5DvciMRI494OapieI9qiODpOt0XBr1LjIDy1xAGAnVs5supTA=="], "@opentelemetry/instrumentation-http/@opentelemetry/instrumentation": ["@opentelemetry/instrumentation@0.57.1", "", { "dependencies": { "@opentelemetry/api-logs": "0.57.1", "@types/shimmer": "^1.2.0", "import-in-the-middle": "^1.8.1", "require-in-the-middle": "^7.1.1", "semver": "^7.5.2", "shimmer": "^1.2.1" }, "peerDependencies": { "@opentelemetry/api": "^1.3.0" } }, "sha512-SgHEKXoVxOjc20ZYusPG3Fh+RLIZTSa4x8QtD3NfgAUDyqdFFS9W1F2ZVbZkqDCdyMcQG02Ok4duUGLHJXHgbA=="], @@ -1574,8 +1571,6 @@ "popmotion/tslib": ["tslib@2.4.0", "", {}, "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ=="], - "postcss/nanoid": ["nanoid@3.3.17", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-xQLf0A3HOMlgHq0n247/LRuAOYmB7dXJ/DvAxGvsSBij45XtBSmQycu+F8ODbHwns/XyFZagyL1+J0Offw1E0g=="], - "style-value-types/tslib": ["tslib@2.4.0", "", {}, "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ=="], "svelte/aria-query": ["aria-query@5.3.1", "", {}, "sha512-Z/ZeOgVl7bcSYZ/u/rh0fOpvEpq//LZmdbkXyc7syVzjPAhfOa9ebsdTSjEBDU4vs5nC98Kfduj1uFo0qyET3g=="], diff --git a/package.json b/package.json index 86727369c..731cb3c05 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "flatted": "^3.4.2", "ignore": "^6.0.2", "json5": "^2.2.3", - "nanoid": "^5.1.16", + "nanoid": "^3.3.18", "nanotar": "^0.3.0", "pretty-bytes": "^6.1.1", "remarkable": "^2.0.1", @@ -113,6 +113,7 @@ "picomatch": "^4.0.4", "cookie": "^0.7.0", "ws": "^8.21.0", - "postcss": "^8.5.18" + "postcss": "^8.5.18", + "nanoid": "^3.3.18" } } From f5b26992c53f743208af9e06fb22cc231369b95c Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Fri, 14 Aug 2026 18:09:39 +0530 Subject: [PATCH 16/22] Remove the Cloud public beta card route MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /console/card and /console/card/ served the 2023 Cloud public beta shareable card. The API no longer serves /cards/cloud, so both loaders already bounced to / — the pages were unreachable. getCampaignImageUrl was the only live export under the route and has nothing to do with the card, so it moves to $lib/helpers/campaign.ts next to its one consumer, the unauthenticated layout. getCardImgUrls went with the route; the [uid] loader kept its own copy. windowFocus.ts had no consumer besides Card.svelte, and the console layout's /card path check guarded a route that never rendered under that group. --- src/lib/helpers/campaign.ts | 7 + src/lib/layout/unauthenticated.svelte | 2 +- src/lib/stores/windowFocus.ts | 29 -- src/routes/(console)/+layout.svelte | 1 - src/routes/(public)/card/+layout.svelte | 9 - src/routes/(public)/card/+page.ts | 10 - src/routes/(public)/card/Card.svelte | 458 -------------------- src/routes/(public)/card/[uid]/+page.svelte | 433 ------------------ src/routes/(public)/card/[uid]/+page.ts | 57 --- src/routes/(public)/card/helpers.ts | 17 - 10 files changed, 8 insertions(+), 1015 deletions(-) create mode 100644 src/lib/helpers/campaign.ts delete mode 100644 src/lib/stores/windowFocus.ts delete mode 100644 src/routes/(public)/card/+layout.svelte delete mode 100644 src/routes/(public)/card/+page.ts delete mode 100644 src/routes/(public)/card/Card.svelte delete mode 100644 src/routes/(public)/card/[uid]/+page.svelte delete mode 100644 src/routes/(public)/card/[uid]/+page.ts delete mode 100644 src/routes/(public)/card/helpers.ts diff --git a/src/lib/helpers/campaign.ts b/src/lib/helpers/campaign.ts new file mode 100644 index 000000000..1018d668f --- /dev/null +++ b/src/lib/helpers/campaign.ts @@ -0,0 +1,7 @@ +import { getApiEndpoint } from '$lib/stores/sdk'; + +export function getCampaignImageUrl(image: string) { + const endpoint = getApiEndpoint(); + const url = new URL(image, endpoint); + return url.toString(); +} diff --git a/src/lib/layout/unauthenticated.svelte b/src/lib/layout/unauthenticated.svelte index 27b44f624..d68dcfa86 100644 --- a/src/lib/layout/unauthenticated.svelte +++ b/src/lib/layout/unauthenticated.svelte @@ -7,7 +7,7 @@ import LoginLight from '$lib/images/login/login-light-mode.png'; import { app } from '$lib/stores/app'; import { Typography, Layout, Avatar } from '@appwrite.io/pink-svelte'; - import { getCampaignImageUrl } from '$routes/(public)/card/helpers'; + import { getCampaignImageUrl } from '$lib/helpers/campaign'; import { isSmallViewport } from '$lib/stores/viewport'; import type { Models } from '@appwrite.io/console'; diff --git a/src/lib/stores/windowFocus.ts b/src/lib/stores/windowFocus.ts deleted file mode 100644 index b0c28abca..000000000 --- a/src/lib/stores/windowFocus.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { readable, type Readable } from 'svelte/store'; - -function isCurrentWindowFocused(): boolean { - if (!window) return false; - if (!window.document) return false; - if (typeof window.document.hasFocus !== 'function') return false; - - return window.document.hasFocus(); -} - -export function windowFocusStore(): Readable { - const visibility = readable(isCurrentWindowFocused(), (set) => { - function handler() { - set(isCurrentWindowFocused()); - } - - if (window) { - window.addEventListener('focus', handler); - window.addEventListener('blur', handler); - - return () => { - window.removeEventListener('focus', handler); - window.removeEventListener('blur', handler); - }; - } - }); - - return visibility; -} diff --git a/src/routes/(console)/+layout.svelte b/src/routes/(console)/+layout.svelte index 139f1883d..b0f426798 100644 --- a/src/routes/(console)/+layout.svelte +++ b/src/routes/(console)/+layout.svelte @@ -331,7 +331,6 @@ - import { Shell } from '$lib/layout'; - import Footer from '$lib/layout/footer.svelte'; - - - - -