Skip to content

iOS Shortcut API key creation reads res.key instead of res.data.key, always yields undefined #1541

Closed

Description

@rajarshidattapy

Severity: High (feature is broken)
File: apps/web/components/settings/integrations.tsx:147-160

Description

authClient.apiKey.create() (better-auth) resolves to { data, error }, not the
key object directly. createApiKeyMutation unwraps it wrong:

const res = await authClient.apiKey.create({ ... })
return res.key            // always undefined

onSuccess then does setApiKey(undefined), opens the modal, and calls
handleCopyApiKey(undefined).

Every other call site in the repo unwraps it correctly:

File Handling
apps/web/components/integrations/raycast-detail.tsx:60 res.data?.key ✅
apps/web/components/integrations/shortcuts-detail.tsx:88 res.data?.key ✅
apps/web/components/settings/api-keys.tsx:196 extractCreatedKey(res) ✅
apps/web/components/settings/integrations.tsx:186 (Raycast, same file) res.data?.key ✅
apps/web/components/settings/integrations.tsx:155 (iOS Shortcut) res.key ❌

The mutation still "succeeds", so the user gets a modal with an empty key and a
clipboard copy that silently no-ops — no error surfaces. A key is created
server-side each time, so retrying leaks orphaned keys into the org.

TypeScript already flags this:

components/settings/integrations.tsx(155,15): error TS2339:
  Property 'key' does not exist on type 'Data<{ key: string; ... }> | Error$1<...>'

Suggested fix

Match the Raycast mutation 20 lines below it:

if (!res.data?.key) throw new Error("API key missing from response")
return res.data.key

Activity

  1. linear-code commented on Aug 19, 2026

    @linear-code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions