{"record":{"id":"58482cb8c548ede6","repo":"GitbookIO/gitbook","slug":"no-documentation-page-is-currently-open-to-submit","errorCode":null,"errorMessage":"No documentation page is currently open to submit feedback for.","messagePattern":"No documentation page is currently open to submit feedback for\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/gitbook/src/components/AI/useSubmitPageFeedbackTool.ts","lineNumber":101,"sourceCode":"                \"Submit the feedback on behalf of the user about the documentation page they are currently viewing. Use this when the user is indicating a sentiment about the page, particularly a negative one, or pointing to incorrect or incoherent information on a page. Proactively suggest to submit feedback for the user to help alleviate frustration or indicate a content gap they've encountered. The user will be asked to confirm before the feedback is recorded. Provide a rating and, when the user gave one, a comment in their own words.\",\n            confirmation: (input) => {\n                const parsed = SubmitPageFeedbackInputSchema.safeParse(input);\n                const comment = parsed.success ? parsed.data.comment?.trim() : undefined;\n                return {\n                    icon: 'paper-plane',\n                    label: tString(language, 'ai_chat_tools_submit_feedback', ''),\n                    context: comment ? `\"${comment}\"` : undefined,\n                };\n            },\n            inputSchema: zodToJsonSchema(\n                SubmitPageFeedbackInputSchema as any\n            ) as AIToolDefinition['inputSchema'],\n            execute: async (input) => {\n                const { trackEvent, language, currentPage, displayContext } = ref.current;\n                const { rating, comment } = SubmitPageFeedbackInputSchema.parse(input);\n\n                if (!currentPage) {\n                    throw new Error(\n                        'No documentation page is currently open to submit feedback for.'\n                    );\n                }\n\n                const pageFeedbackRating = ratingByInput[rating];\n                const trimmedComment = comment?.trim() || undefined;\n\n                const pageContext: InsightsEventPageContext = {\n                    pageId: currentPage.pageId,\n                    displayContext,\n                };\n\n                trackEvent(\n                    { type: 'page_post_feedback', feedback: { rating: pageFeedbackRating } },\n                    pageContext,\n                    { immediate: !trimmedComment }\n                );\n","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/GitbookIO/gitbook/blob/db67585ee243d063c459a855988f21612cea9c95/packages/gitbook/src/components/AI/useSubmitPageFeedbackTool.ts#L83-L119","documentation":"Thrown by the submit_page_feedback AI tool (useSubmitPageFeedbackTool) when it runs while currentPage is null in its ref state. The tool needs the currently open documentation page to attribute the feedback event; if the assistant is rendered in a context with no ambient current page (e.g. a standalone/embed assistant tab not bound to a page), the execute throws.","triggerScenarios":"Executing the page-feedback tool when ref.current.currentPage is null — e.g. the assistant runs on a non-page route or in the embed's assistant tab with no page context; the page context wasn't propagated to the component providing the tool; invoking the tool from a search/ask flow that never resolved to a page.","commonSituations":"Using the embedded assistant outside documentation pages; a custom integration rendering AI chat without passing the current page; refactors that stopped populating currentPage in the tool's ref.","solutions":["Pass the current page into the component that creates the tool (ensure currentPage in ref is set from your routing/page context).","In the tool wrapper, return a graceful 'cannot submit page feedback here' result instead of throwing when currentPage is null.","Restrict the tool: only register submit_page_feedback when the assistant is bound to a page context (filter available tools by display context).","If embedding, open the assistant from within a documentation page so page context exists."],"exampleFix":"// before\nif (!currentPage) {\n    throw new Error('No documentation page is currently open to submit feedback for.');\n}\n\n// after\nif (!currentPage) {\n    return { success: false, reason: 'no-page-open' };\n}","handlingStrategy":"validation","validationCode":"if (!currentPage) {\n    // skip registering / calling the page feedback tool\n    return tools.filter((tool) => tool.name !== 'submit_page_feedback');\n}","typeGuard":"const hasCurrentPage = (\n    ctx: { currentPage?: CurrentPageInfo | null }\n): ctx is { currentPage: CurrentPageInfo } => !!ctx.currentPage;","tryCatchPattern":"try {\n    await submitPageFeedbackTool.execute(input);\n} catch (error) {\n    if (error instanceof Error && error.message.includes('No documentation page')) {\n        return { success: false, reason: 'no-page' };\n    }\n    throw error;\n}","preventionTips":["Only register the page-feedback tool in page-bound display contexts.","Wire your routing state into currentPage in the tool's ref.","Return structured failures from tools instead of throwing for expected conditions."],"tags":["ai","tools","feedback","page-context","gitbook"],"backgroundTag":"missing-context-value","analyzedSha":"db67585ee243d063c459a855988f21612cea9c95","analyzedAt":"2026-08-28T17:49:47.831Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}