{"record":{"id":"cc007dbb622dbc09","repo":"GitbookIO/gitbook","slug":"ai-search-is-not-enabled-for-this-site","errorCode":null,"errorMessage":"AI Search is not enabled for this site.","messagePattern":"AI Search is not enabled for this site\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/gitbook/src/components/Search/server-actions.tsx","lineNumber":61,"sourceCode":"export async function streamAskQuestion({\n    asEmbeddable,\n    question,\n    session,\n}: {\n    asEmbeddable?: boolean;\n    question: string;\n    session: SiteInsightsSession;\n}) {\n    return traceErrorOnly('Search.streamAskQuestion', async () => {\n        const responseStream = createStreamableValue<AskAnswerResult | undefined>();\n\n        (async () => {\n            const context = await fetchServerActionSiteContext(\n                await getServerActionBaseContext({ isEmbeddable: asEmbeddable })\n            );\n\n            if (!isAISearchEnabled(context.customization.ai.mode)) {\n                throw new Error('AI Search is not enabled for this site.');\n            }\n\n            const apiClient = await context.dataFetcher.api();\n\n            const stream = apiClient.orgs.streamAskInSite(\n                context.organizationId,\n                context.site.id,\n                {\n                    question,\n                    context: {\n                        siteSpaceId: context.siteSpace.id,\n                    },\n                    scope: {\n                        mode: 'default',\n                        currentSiteSpace: context.siteSpace.id,\n                    },\n                    session,\n                },","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/GitbookIO/gitbook/blob/db67585ee243d063c459a855988f21612cea9c95/packages/gitbook/src/components/Search/server-actions.tsx#L43-L79","documentation":"Thrown by the streamAskQuestion server action (AI Search 'ask' stream) when the site's AI mode does not enable AI search. Like the chat gate, it fetches server action site context and checks isAISearchEnabled(context.customization.ai.mode); any mode that doesn't include search causes the action to abort before opening the API stream.","triggerScenarios":"Calling streamAskQuestion on a site whose customization.ai.mode is 'disabled'; a mode that enables only chat but not search (search-only vs chat-only mode mismatch); stale cached customization after the mode was changed; pointing at the wrong org/site so the fetched context has AI off.","commonSituations":"Site configured with chat-only AI while the UI still exposes the search 'ask' entry; AI turned off org-wide but an old client bundle still calls the action; embedding search on sites where AI was never enabled.","solutions":["Set the site/space AI customization to a mode that enables AI Search (or full AI) in GitBook settings.","Gate the ask-in-search UI on the same isAISearchEnabled(customization.ai.mode) check so the action isn't called when disabled.","Confirm org/site resolution (URL data / middleware) points at the site you configured.","Refresh cache / redeploy so updated customization reaches the server action."],"exampleFix":"// before\nconst stream = streamAskQuestion({ question });\n\n// after\nconst aiSearchEnabled = isAISearchEnabled(customization.ai.mode);\nconst stream = aiSearchEnabled ? streamAskQuestion({ question }) : null;","handlingStrategy":"validation","validationCode":"if (!isAISearchEnabled(customization.ai.mode)) {\n    disableAskInSearchUI();\n} else {\n    streamAskQuestion({ question });\n}","typeGuard":"const aiModeEnablesSearch = (\n    mode: string | undefined\n): mode is string => isAISearchEnabled(mode);","tryCatchPattern":"try {\n    const stream = streamAskQuestion(input);\n} catch (error) {\n    if (error instanceof Error && error.message.includes('not enabled')) {\n        showFeatureDisabledNotice();\n        return;\n    }\n    throw error;\n}","preventionTips":["Check the same ai.mode gate client-side before invoking the action.","Keep site customization in sync between server actions and UI state.","Cover mode variants (disabled/search/chat) in tests of search entry points."],"tags":["ai","search","feature-flag","configuration","server-action","gitbook"],"backgroundTag":"feature-not-enabled","analyzedSha":"db67585ee243d063c459a855988f21612cea9c95","analyzedAt":"2026-08-28T17:49:47.831Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}