RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Fix: An error occurs when accessing the Go version of the wiki page. (#18835)
balibabu0f08bf1d16cf
diff --git a/web/.oxlintrc.json b/web/.oxlintrc.jsonindex 93893e0732..097846896a 100644--- a/web/.oxlintrc.json+++ b/web/.oxlintrc.json@@ -36,6 +36,13 @@}]}+ ],+ "no-restricted-globals": [+ "error",+ {+ "name": "__API_PROXY_SCHEME__",+ "message": "Backend identity comes from runtime detection, not the dev-proxy env. Branch only through @/utils/backend-variant (useIsGoBackend / <BackendVariant> / pickByBackend); do not declare or read API_PROXY_SCHEME in app code."+ }]}}diff --git a/web/CLAUDE.md b/web/CLAUDE.mdindex 8d69303e86..98dea3a38d 100644--- a/web/CLAUDE.md+++ b/web/CLAUDE.md@@ -41,6 +41,7 @@ All divergence between the two backends is funneled through dispatch points. Bus3. Routes never fork per backend: one route, one dispatcher component, with the variant implementations under `go/` and `python/` subdirectories. Reference example: `src/pages/dataset/setting/`.4. Variant file naming: `Xxx.go.tsx` / `Xxx.python.ts(x)` siblings behind a same-named dispatcher, or `go/` + `python/` subdirectories for whole pages. No temporal names (`Next`, `Legacy`, `New`).5. Small differences (a field's visibility, a field name) belong in capability-style adapter/config files reached through `pickByBackend`, not scattered inline ternaries in shared components.+6. Runtime detection (`/api/v1/language`) is the ONLY source of backend identity in app code. Never read `API_PROXY_SCHEME` / `__API_PROXY_SCHEME__` or declare that global in `src/`, and never create another backend-detection helper (a deleted `api-proxy-scheme.ts` did exactly this — do not recreate it). The env var only configures the dev-server proxy in `vite.config.ts`; it is build-time, dev-only, and defaults to `python`, so it cannot say which backend is actually serving (enforced by oxlint `no-restricted-globals` for bare reads; the Vite `define` that injected it into the client bundle is removed).Migration status: complete. All former `isGoBackend()` call sites go through the primitives — per-variant transforms are dispatched inside `src/pages/agent/utils.ts` and `src/utils/pipeline-operator.ts`, extractor initial values inside `src/pages/agent/constant/pipeline.tsx`, the parser-change dialog inside `src/pages/dataset/dataset/change-parser-dialog.tsx`, and the dataset configuration route is a single dispatcher (`src/pages/dataset/setting/`). `no-restricted-imports` is enforced at `error`.diff --git a/web/src/hooks/__tests__/use-dataset-generate-status.test.tsx b/web/src/hooks/__tests__/use-dataset-generate-status.test.tsxindex 8e275d57e2..d19e2f6b8c 100644--- a/web/src/hooks/__tests__/use-dataset-generate-status.test.tsx+++ b/web/src/hooks/__tests__/use-dataset-generate-status.test.tsx@@ -9,8 +9,8 @@ jest.mock('react-router', () => ({useParams: jest.fn(() => ({ id: 'kb1' })),}));-jest.mock('@/utils/api-proxy-scheme', () => ({- isGoDatasetBackend: jest.fn(() => true),+jest.mock('@/utils/backend-variant', () => ({+ useIsGoBackend: jest.fn(() => true),}));jest.mock('@/services/knowledge-service', () => ({@@ -30,7 +30,7 @@ jest.mock('react-i18next', () => ({}));import { getDatasetCompilationStatus } from '@/services/knowledge-service';-import { isGoDatasetBackend } from '@/utils/api-proxy-scheme';+import { useIsGoBackend } from '@/utils/backend-variant';const mockStatus = jest.mocked(getDatasetCompilationStatus);@@ -53,10 +53,10 @@ function makeWrapper() {return Wrapper;}-describe('useTraceRunData (Go/hybrid compile-status contract)', () => {+describe('useTraceRunData (Go compile-status contract)', () => {beforeEach(() => {jest.clearAllMocks();- (isGoDatasetBackend as jest.Mock).mockReturnValue(true);+ (useIsGoBackend as jest.Mock).mockReturnValue(true);});it('maps a successful status to the scheduler contract fields', async () => {diff --git a/web/src/hooks/use-dataset-generate.ts b/web/src/hooks/use-dataset-generate.tsindex 86d3165a6d..42c35ae7f1 100644--- a/web/src/hooks/use-dataset-generate.ts+++ b/web/src/hooks/use-dataset-generate.ts@@ -29,7 +29,7 @@ import {runIndex,traceIndex,} from '@/services/knowledge-service';-import { isGoDatasetBackend } from '@/utils/api-proxy-scheme';+import { useIsGoBackend } from '@/utils/backend-variant';import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';import { useMemo } from 'react';import { useTranslation } from 'react-i18next';@@ -66,11 +66,11 @@ export interface ITraceInfo {to_page: number;update_date: string;update_time: number;- // Go scheduler compile-status contract (API_PROXY_SCHEME=go/hybrid). These+ // Go scheduler compile-status contract. These// replace the legacy task percentage for the Go backend: state is the raw// dataset-level lifecycle (idle/pending/running/completed), inflight/backlog// are the MySQL scheduling-entry counts, and error is the batch diagnostic- // (NOT a peer state). Only populated by the Go/hybrid branch of useTraceQuery.+ // (NOT a peer state). Only populated by the Go branch of useTraceQuery.compilationState?: string;currentPhase?: string;inflight?: number;@@ -84,15 +84,16 @@ const useTraceQuery = (open: boolean,id?: string,) => {+ const isGo = useIsGoBackend();return useQuery<ITraceInfo>({queryKey: DatasetGenerateKeys.trace(type, id, open),gcTime: 0,refetchInterval: (query) => {const progress = query.state.data?.progress;- // Go/hybrid: keep polling while the dataset compile is pending/running+ // Go: keep polling while the dataset compile is pending/running// (a failed batch is left for retry, so the row stays running/pending and// we keep polling until it drains to completed).- if (isGoDatasetBackend()) {+ if (isGo) {const state = query.state.data?.compilationState;return state === 'pending' || state === 'running'? PollIntervalMs@@ -106,7 +107,7 @@ const useTraceQuery = (retryDelay: 1000,enabled: open && !!id,queryFn: async () => {- if (isGoDatasetBackend()) {+ if (isGo) {// Scheduler compile-status contract (dataset-level, variant-agnostic).// The status is NOT a task percentage: we carry the raw state, the// MySQL inflight/backlog entry counts and the error diagnostic, and@@ -190,6 +191,7 @@ export const useDatasetGenerate = () => {const { id } = useParams();const { handleUnbindTask } = useUnBindTask();const { t } = useTranslation();+ const isGo = useIsGoBackend();const {data,@@ -198,12 +200,12 @@ export const useDatasetGenerate = () => {} = useMutation({mutationKey: [DatasetKey.generate],mutationFn: async ({ type }: { type: GenerateType }) => {- // Go/hybrid: dataset compilation is driven automatically by the scheduler+ // Go: dataset compilation is driven automatically by the scheduler// on document completion; there is no manual RunIndex trigger, so a manual// "generate" must NOT pretend to succeed. The UI hides/disables the// control; if it is ever invoked, reject loudly so callers don't mistake// it for a real run (plan v4.1 §4.2).- if (isGoDatasetBackend()) {+ if (isGo) {throw new Error(t('message.compileNotSupported'));}const { data } = await runIndex(id!, TraceTypeMap[type]);@@ -226,10 +228,10 @@ export const useDatasetGenerate = () => {task_id: string;type: GenerateType;}) => {- // Go/hybrid: the scheduler has no task-level cancel; dataset compilation+ // Go: the scheduler has no task-level cancel; dataset compilation// is auto-driven. There is no pause to perform, so reject rather than// report success (the UI hides the pause control — plan v4.1 §4.2).- if (isGoDatasetBackend()) {+ if (isGo) {throw new Error(t('message.compileNotSupported'));}const { data } = await agentService.cancelDataflow(task_id);@@ -254,12 +256,13 @@ export const useDatasetGenerate = () => {};export function useGenerateStatus(data?: ITraceInfo) {+ const isGo = useIsGoBackend();const status = useMemo(() => {if (!data) {return GenerateStatus.Start;}- if (isGoDatasetBackend()) {- // Go/hybrid: derive from the scheduler contract, not a fake task+ if (isGo) {+ // Go: derive from the scheduler contract, not a fake task// percentage. Error diagnostic takes priority; otherwise map the raw// dataset-level state (completed->Completed, idle->Start, running/pending// ->Running).@@ -281,10 +284,10 @@ export function useGenerateStatus(data?: ITraceInfo) {return GenerateStatus.Running;}return GenerateStatus.Start;- }, [data]);+ }, [data, isGo]);const percent = useMemo(() => {- if (isGoDatasetBackend()) {+ if (isGo) {return status === GenerateStatus.Failed? 100: (data?.progress ?? 0) * 100;@@ -295,7 +298,7 @@ export function useGenerateStatus(data?: ITraceInfo) {return data!.progress * 100;}return 0;- }, [status, data]);+ }, [status, data, isGo]);return { status, percent };}diff --git a/web/src/hooks/use-knowledge-request.ts b/web/src/hooks/use-knowledge-request.tsindex e49bff35e6..3665d6a216 100644--- a/web/src/hooks/use-knowledge-request.ts+++ b/web/src/hooks/use-knowledge-request.ts@@ -16,7 +16,7 @@import { useHandleFilterSubmit } from '@/components/list-filter-bar/use-handle-filter-submit';import message from '@/components/ui/message';-import { isGoDatasetBackend } from '@/utils/api-proxy-scheme';+import { useIsGoBackend } from '@/utils/backend-variant';import { GenerateType, ParseType } from '@/constants/knowledge';import { ResponsePostType, ResponseType } from '@/interfaces/database/base';import {@@ -979,6 +979,7 @@ export const useClearWiki = () => {export const useRunArtifactIndex = (kind: string) => {const knowledgeBaseId = useKnowledgeBaseId();const queryClient = useQueryClient();+ const isGo = useIsGoBackend();const {data,@@ -987,11 +988,11 @@ export const useRunArtifactIndex = (kind: string) => {} = useMutation({mutationKey: [KnowledgeApiAction.RunArtifactIndex],mutationFn: async () => {- // Go/hybrid: wiki compilation is auto-driven by the scheduler; there is no+ // Go: wiki compilation is auto-driven by the scheduler; there is no// legacy RunIndex endpoint. Reject instead of reporting success so a wiki// update can't be mistaken for a real re-merge (the UI hides/disables the// update control — plan v4.1 §4.2).- if (isGoDatasetBackend()) {+ if (isGo) {throw new Error(i18n.t('message.compileNotSupported'));}const { data } = await runIndex(knowledgeBaseId, 'wiki');diff --git a/web/src/pages/dataset/compilation/empty-state.tsx b/web/src/pages/dataset/compilation/empty-state.tsxindex 5ba2ef9b5e..38771846b4 100644--- a/web/src/pages/dataset/compilation/empty-state.tsx+++ b/web/src/pages/dataset/compilation/empty-state.tsx@@ -9,7 +9,7 @@ import {useDatasetGenerate,useGenerateStatus,} from '@/hooks/use-dataset-generate';-import { isGoDatasetBackend } from '@/utils/api-proxy-scheme';+import { useIsGoBackend } from '@/utils/backend-variant';import {GenerableViewMode,@@ -57,7 +57,7 @@ export function CompilationEmptyState({}, [pauseGenerate, data?.id, generateType]);const showProgress = status === 'running' || status === 'failed';- const isGo = isGoDatasetBackend();+ const isGo = useIsGoBackend();return (<div className="flex-1 min-h-0 flex flex-col items-center justify-center border border-dashed border-border-button rounded-xl">@@ -85,7 +85,7 @@ export function CompilationEmptyState({<div /><div className="flex flex-col items-center gap-5">{isGo ? (- // Go/hybrid: no stable percentage and no scheduler cancel, so show+ // Go: no stable percentage and no scheduler cancel, so show// the MySQL inflight/backlog counts (or the error diagnostic).status === 'failed' ? (<div className="flex flex-col items-center gap-2 text-state-error">diff --git a/web/src/pages/dataset/compilation/update-run-progress.tsx b/web/src/pages/dataset/compilation/update-run-progress.tsxindex c5b2dd18ff..62752ec075 100644--- a/web/src/pages/dataset/compilation/update-run-progress.tsx+++ b/web/src/pages/dataset/compilation/update-run-progress.tsx@@ -9,7 +9,7 @@ import {useDatasetGenerate,useGenerateStatus,} from '@/hooks/use-dataset-generate';-import { isGoDatasetBackend } from '@/utils/api-proxy-scheme';+import { useIsGoBackend } from '@/utils/backend-variant';import { cn } from '@/lib/utils';import { toFixed } from '@/utils/common-util';@@ -25,7 +25,7 @@ export function UpdateRunProgress({const { t } = useTranslation();const { pauseGenerate } = useDatasetGenerate();const { status, percent } = useGenerateStatus(data);- const isGo = isGoDatasetBackend();+ const isGo = useIsGoBackend();const handlePause = useCallback((e: MouseEvent) => {@@ -37,7 +37,7 @@ export function UpdateRunProgress({[pauseGenerate, data?.id, generateType],);- // Go/hybrid: no scheduler task-level cancel, and no stable terminal state, so+ // Go: no scheduler task-level cancel, and no stable terminal state, so// show the MySQL inflight/backlog entry counts instead of a percentage and no// pause button. Error diagnostic takes priority (see plan v4.1 §4.2).if (isGo && status === 'running') {diff --git a/web/src/pages/files/files-table.tsx b/web/src/pages/files/files-table.tsxindex 655875849e..bbfc2b67ba 100644--- a/web/src/pages/files/files-table.tsx+++ b/web/src/pages/files/files-table.tsx@@ -52,7 +52,7 @@ import { LinkToDatasetDialog } from './link-to-dataset-dialog';import { UseMoveDocumentShowType } from './use-move-file';import { useNavigateToOtherFolder } from './use-navigate-to-folder';import { isFolderType, isKnowledgeBaseType } from './util';-import { isGoDatasetBackend } from '../../utils/api-proxy-scheme';+import { useIsGoBackend } from '../../utils/backend-variant';type FilesTableProps = Pick<ReturnType<typeof useFetchFileList>,@@ -102,11 +102,11 @@ export function FilesTable({fileRenameLoading,} = useRenameCurrentFile();- // Check if skills feature is enabled (only in hybrid or go mode)- const isSkillsEnabled = useMemo(() => isGoDatasetBackend(), []);+ // Skills are only served by the Go backend+ const isSkillsEnabled = useIsGoBackend();// Sort files with skills folder first, then by time- // Filter out skills folder if not in hybrid/go mode+ // Filter out the skills folder on the Python backendconst { sortedFiles, hiddenCount } = useMemo(() => {if (!files) return { sortedFiles: [] as IFile[], hiddenCount: 0 };@@ -133,7 +133,10 @@ export function FilesTable({return (b.create_time || 0) - (a.create_time || 0);});- return { sortedFiles: sorted, hiddenCount: files.length - filteredFiles.length };+ return {+ sortedFiles: sorted,+ hiddenCount: files.length - filteredFiles.length,+ };}, [files, isSkillsEnabled]);// Keep the displayed total consistent with the rows actually shown:diff --git a/web/src/services/knowledge-service.ts b/web/src/services/knowledge-service.tsindex e26c954073..dde2382d11 100644--- a/web/src/services/knowledge-service.ts+++ b/web/src/services/knowledge-service.ts@@ -304,7 +304,7 @@ export const traceIndex = (datasetId: string, indexType: string) =>request.get(api.traceIndex(datasetId, indexType));// getDatasetCompilationStatus reads the Go scheduler compile-status contract-// (GET /datasets/:id/compilation/status), used by API_PROXY_SCHEME=go/hybrid to+// (GET /datasets/:id/compilation/status), used on the Go backend to// replace the legacy traceIndex task-progress endpoint. Route it through the// service-layer proxy (registerNextServer -> next-request) like the rest of the// *-service.ts HTTP proxies.diff --git a/web/src/utils/api-proxy-scheme.ts b/web/src/utils/api-proxy-scheme.tsdeleted file mode 100644index 033440cd7a..0000000000--- a/web/src/utils/api-proxy-scheme.ts+++ /dev/null@@ -1,64 +0,0 @@-/*- * Copyright 2026 The InfiniFlow Authors. All Rights Reserved.- *- * Licensed under the Apache License, Version 2.0 (the "License");- * you may not use this file except in compliance with the License.- * You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--/**- * Shared helper for the Vite-injected `API_PROXY_SCHEME` runtime value.- *- * Vite (web/vite.config.ts) injects `__API_PROXY_SCHEME__` from- * `import.meta.env.API_PROXY_SCHEME`. It selects which backend serves the- * dataset compilation / index APIs:- *- * - `python`: all /api requests go to the Python backend (9380); the legacy- * `/datasets/:id/index` run/trace endpoints remain valid.- * - `go`: all /api requests go to the Go backend (9384); the legacy- * `/datasets/:id/index` routes are removed, so UI must use the scheduler- * compile-status contract instead.- * - `hybrid`: Vite routes `/api/v1/datasets` to the Go backend (9384);- * dataset compilation logic behaves like `go`.- *- * Default is `python` for safety (matches Vite's fallback).- *- * All pages must read the scheme through these predicates instead of scattering- * `typeof __API_PROXY_SCHEME__` checks (see files-table.tsx, which previously- * inlined this logic).- */--declare const __API_PROXY_SCHEME__: string;--export type ApiProxyScheme = 'python' | 'go' | 'hybrid';--export function getApiProxyScheme(): ApiProxyScheme {- const raw = typeof __API_PROXY_SCHEME__ !== 'undefined' ? __API_PROXY_SCHEME__ : '';- switch (raw) {- case 'go':- case 'hybrid':- case 'python':- return raw;- default:- return 'python';- }-}--/** True when the dataset compilation APIs are served by the Go backend. */-export function isGoDatasetBackend(): boolean {- const s = getApiProxyScheme();- return s === 'go' || s === 'hybrid';-}--/** True when the legacy Python run/trace `/index` endpoints are in use. */-export function isPythonDatasetBackend(): boolean {- return getApiProxyScheme() === 'python';-}diff --git a/web/src/utils/api.ts b/web/src/utils/api.tsindex 35f9e4cb98..a71be1a252 100644--- a/web/src/utils/api.ts+++ b/web/src/utils/api.ts@@ -231,7 +231,7 @@ export default {`${restAPIv1}/datasets/${datasetId}/index?type=${indexType.toLowerCase()}`,traceIndex: (datasetId: string, indexType: string) =>`${restAPIv1}/datasets/${datasetId}/index?type=${indexType.toLowerCase()}`,- // Go scheduler compile-status contract (API_PROXY_SCHEME=go/hybrid).+ // Go scheduler compile-status contract.compilationStatus: (datasetId: string) =>`${restAPIv1}/datasets/${datasetId}/compilation/status`,unbindPipelineTask: (datasetId: string, indexType: string, wipe?: boolean) =>diff --git a/web/vite.config.ts b/web/vite.config.tsindex 3cd9b16c50..8bcd60a7b2 100644--- a/web/vite.config.ts+++ b/web/vite.config.ts@@ -141,12 +141,6 @@ export default defineConfig(({ mode }) => {const proxy = proxySchemes[proxyScheme] || proxySchemes.python;return {- define: {- // Expose to client code via import.meta.env- 'import.meta.env.API_PROXY_SCHEME': JSON.stringify(proxyScheme),- // Keep backward compatibility- __API_PROXY_SCHEME__: JSON.stringify(proxyScheme),- },plugins: [inspectorBabelPlugin(),react(),