{"record":{"id":"0f3bee21fa91cc7d","repo":"infiniflow/ragflow","slug":"failed-to-update-search","errorCode":null,"errorMessage":"Failed to update search","messagePattern":"Failed to update search","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"web/src/pages/next-searches/hooks.ts","lineNumber":313,"sourceCode":"\nexport type IUpdateSearchProps = Omit<ISearchAppDetailProps, 'id'> & {\n  search_id: string;\n};\n\nexport const useUpdateSearch = () => {\n  const { t } = useTranslation();\n  const queryClient = useQueryClient();\n  const {\n    data,\n    isError,\n    mutateAsync: updateSearchMutation,\n  } = useMutation<any, Error, IUpdateSearchProps>({\n    mutationKey: ['updateSearch'],\n    mutationFn: async (formData) => {\n      const { data: response } =\n        await searchService.updateSearchSetting(formData);\n      if (response.code !== 0) {\n        throw new Error(response.message || 'Failed to update search');\n      }\n      return response.data;\n    },\n    onSuccess: (data, variables) => {\n      message.success(t('message.updated'));\n      queryClient.invalidateQueries({\n        queryKey: ['searchDetail', variables.search_id],\n      });\n    },\n  });\n\n  const updateSearch = useCallback(\n    (formData: IUpdateSearchProps) => {\n      return updateSearchMutation(formData);\n    },\n    [updateSearchMutation],\n  );\n","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/web/src/pages/next-searches/hooks.ts#L295-L331","documentation":"Thrown by the useUpdateSearch mutation in web/src/pages/next-searches/hooks.ts:313 when searchService.updateSearchSetting resolves with a non-zero business code. RAGFlow APIs wrap failures in code !== 0 even on HTTP 200, so this error means the server rejected the update payload — typically invalid settings, unknown search_id, or a validation failure. The message shown is the fallback string when the server omits message.","triggerScenarios":"Submitting updateSearchSetting with a search_id that does not exist; sending an invalid configuration field (bad similarity threshold, unknown embedding model id); expired auth token causing the backend to return an error code; concurrency — the search was deleted while the settings form was open.","commonSituations":"Long-lived settings modal where the entity was removed elsewhere. Backend upgrade changed accepted fields. Form validation gaps letting malformed numbers/strings through. Non-owner user attempting the update.","solutions":["Inspect response.code and response.message from updateSearchSetting to identify the concrete server rejection","Validate the form payload against the current API schema (required fields, ranges) before mutating","Confirm search_id matches an existing search by refetching searchDetail first","Refresh auth/session and retry once if the code indicates an auth failure","Check backend logs for the update endpoint's validation errors"],"exampleFix":"// before\nif (response.code !== 0) {\n  throw new Error(response.message || 'Failed to update search');\n}\n\n// after\nif (response.code !== 0) {\n  throw new Error(\n    `[${response.code}] ${response.message || 'Failed to update search'}`,\n  );\n}","handlingStrategy":"validation","validationCode":"const canUpdate = (p: IUpdateSearchProps) =>\n  Boolean(p.search_id) && Object.keys(p).length > 1;","typeGuard":"const hasSearchId = (p: unknown): p is IUpdateSearchProps =>\n  typeof p === 'object' && p !== null && typeof p.search_id === 'string' && p.search_id.length > 0;","tryCatchPattern":"try {\n  await updateSearchMutation(formData);\n} catch (e) {\n  message.error(e.message || 'update failed'); // surface server message\n}","preventionTips":["Refetch searchDetail before opening the settings form to catch deleted searches early","Validate form field ranges client-side against the backend schema"],"tags":["react-query","api-contract","search","form-validation"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}