From caeaa172b7bf6c90504cc19426bd4c50c7faaa81 Mon Sep 17 00:00:00 2001 From: hugocasa Date: Fri, 7 Aug 2026 12:50:25 +0200 Subject: [PATCH] fix: report the by-hash error when a hash URL fails both lookups Co-Authored-By: Claude Opus 5 (1M context) --- .../(logged)/scripts/get/[...hash]/+page.svelte | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/frontend/src/routes/(root)/(logged)/scripts/get/[...hash]/+page.svelte b/frontend/src/routes/(root)/(logged)/scripts/get/[...hash]/+page.svelte index d57ced8a1b..51d83acf63 100644 --- a/frontend/src/routes/(root)/(logged)/scripts/get/[...hash]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/scripts/get/[...hash]/+page.svelte @@ -242,13 +242,15 @@ } isHubScript = false + let byHashError: any try { script = await ScriptService.getScriptByHash({ workspace: $workspaceStore!, hash, withStarredInfo: true }) - } catch { + } catch (e) { + byHashError = e try { script = await ScriptService.getScriptByPath({ workspace: $workspaceStore!, @@ -257,7 +259,11 @@ }) hash = script.hash } catch (e) { - sendUserToast('Could not load script: ' + e.body, true) + // This route takes either a hash or a path, so both lookups are tried. + // Report the one that matches what was actually addressed, otherwise a + // permission failure on a hash surfaces as "no script at path ". + const err = /^[0-9a-f]{16}$/.test(hash) ? byHashError : e + sendUserToast('Could not load script: ' + err.body, true) return } } @@ -469,7 +475,8 @@ label: editInForkLabel($workspaceStore, $userWorkspaces), buttonProps: { href: buildForkEditUrl('script', script.path), - onClick: (e: Event | undefined) => onEditInForkClick(e, 'script', script.path, { hasHref: true }), + onClick: (e: Event | undefined) => + onEditInForkClick(e, 'script', script.path, { hasHref: true }), unifiedSize: 'md', variant: !showEditButtons ? 'default' : 'subtle', startIcon: Pen