{"record":{"id":"4e7f0e46d9ae2d3e","repo":"deepseek-ai/deepseek-harness","slug":"permission-switch-failed-result-error-code","errorCode":null,"errorMessage":"permission switch failed: ${result.error.code}: ${result.error.message}","messagePattern":"permission switch failed: (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/client/ui-permission-presets/src/client/index.ts","lineNumber":153,"sourceCode":"\n  ctx.effect(() => command.decorate({\n    name: 'permission',\n    // The picker exists exactly while the projection does: a permission-less\n    // host serves no key and the bare invocation falls through to the host\n    // command (which is absent too — the line simply misses).\n    available: session => selectOf(sessionFor(session)) !== undefined,\n    ui: {\n      kind: 'popupSelect',\n      options: (session) => {\n        const value = selectOf(sessionFor(session))\n        if (value === undefined) throw new Error('permission presets are not available on this host')\n        return Promise.resolve(optionsOf(value, t))\n      },\n      onSelect: async (option, session) => {\n        const live = sessionFor(session)\n        if (live === undefined) throw new Error('this session is not materialized yet')\n        const result = await live.command(`/permission ${option.id}`)\n        if (!result.ok) throw new Error(`permission switch failed: ${result.error.code}: ${result.error.message}`)\n        if (!result.value.matched) throw new Error('the host offers no /permission command')\n      },\n    },\n  }), 'ui-permission: /permission decoration')\n}\n","sourceCodeStart":135,"sourceCodeEnd":159,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/client/ui-permission-presets/src/client/index.ts#L135-L159","documentation":"The /permission decoration's onSelect switches presets by running the literal line '/permission <option.id>' through the live session's command API. A non-ok RPC result throws 'permission switch failed: <code>: <message>'; a delivered but unmatched line is reported separately (error 197). The 'not materialized yet' sibling check guards the session lookup before this call.","triggerScenarios":"Selecting a permission preset while the command RPC fails: the session dropped, the host command handler errored, or the transport reset mid-call.","commonSituations":"A connection blip while the user picks a preset; the host restarting; an authorization failure for the command execution.","solutions":["Inspect the embedded code/message for the host-side reason","Reconnect and select the preset again","Confirm sessionFor(session) returned a live session before offering the control"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (sessionFor(session) === undefined) return // not materialized yet","typeGuard":null,"tryCatchPattern":"try {\n  await applyPreset(option.id)\n} catch (error) {\n  surfacePermissionError(error) // keep the current selection visible\n}","preventionTips":["Verify the session is materialized before rendering the preset control","Report the embedded code so users can distinguish transport from policy failures"],"tags":["rpc","permissions","slash-commands","ui"],"backgroundTag":"rpc-request-failed","analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}