{"record":{"id":"3c278d6467d007a5","repo":"github/copilot-sdk","slug":"user-input-requested-but-no-handler-registered","errorCode":null,"errorMessage":"User input requested but no handler registered","messagePattern":"User input requested but no handler registered","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nodejs/src/session.ts","lineNumber":1953,"sourceCode":"                // No callback for this section — pass through unchanged\n                result[sectionId] = { content };\n            }\n        }\n\n        return { sections: result };\n    }\n\n    /**\n     * Handles a user input request from the Copilot CLI.\n     *\n     * @param request - The user input request data from the CLI\n     * @returns A promise that resolves with the user's response\n     * @internal This method is for internal use by the SDK.\n     */\n    async _handleUserInputRequest(request: unknown): Promise<UserInputResponse> {\n        if (!this.userInputHandler) {\n            // No handler registered, throw error\n            throw new Error(\"User input requested but no handler registered\");\n        }\n\n        try {\n            const result = await this.userInputHandler(request as UserInputRequest, {\n                sessionId: this.sessionId,\n            });\n            return result;\n        } catch (error) {\n            // Handler failed, rethrow\n            throw error;\n        }\n    }\n\n    /**\n     * Handles a hooks invocation from the Copilot CLI.\n     *\n     * @param hookType - The type of hook being invoked\n     * @param input - The input data for the hook","sourceCodeStart":1935,"sourceCodeEnd":1971,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/nodejs/src/session.ts#L1935-L1971","documentation":"Thrown by CopilotSession._handleUserInputRequest when the host requests user input but the application never registered a userInputHandler. Without a handler the SDK has no way to obtain a user response, so it throws instead of hanging or returning a bogus answer.","triggerScenarios":"Host sends a user-input request to a session where no userInputHandler was registered; application forgot to call the handler-registration API; handler registered on a different session instance.","commonSituations":"Running the SDK in an automated/CI context where interactive input was never wired; onboarding code samples that omit user-input registration; session recreation that lost the previously registered handler.","solutions":["Register a user input handler on the session (set userInputHandler via the provided API) before handling requests","If interactivity is not possible, register a stub handler that returns a default/denial UserInputResponse","Verify the handler is registered on the same session instance receiving the request"],"exampleFix":"// before\nconst session = new CopilotSession(...); // no handler\n// after\nconst session = new CopilotSession(...);\nsession.setUserInputHandler(async (request, { sessionId }) => ({\n  action: \"respond\",\n  value: await promptUser(request),\n}));","handlingStrategy":"try-catch","validationCode":"if (typeof session.getUserInputHandler !== \"function\" || session.getUserInputHandler() == null) {\n  session.setUserInputHandler(defaultHandler);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await session._handleUserInputRequest(request);\n} catch (err) {\n  if (err?.message === \"User input requested but no handler registered\") {\n    return { action: \"reject\", reason: \"no interactive handler available\" };\n  }\n  throw err;\n}","preventionTips":["Register a userInputHandler during session setup, including a non-interactive default for CI","Re-register handlers whenever a session is recreated","Decide up front whether the app can be interactive and configure accordingly"],"tags":["user-input","handler","missing-registration"],"backgroundTag":"missing-required-config","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}