{"record":{"id":"8536ea577d6b49eb","repo":"yikart/AiToEarn","slug":"errors-loadfailed","errorCode":null,"errorMessage":"errors.loadFailed","messagePattern":"errors\\.loadFailed","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"project/aitoearn-web/src/app/layout/ConfigManagerDialog/index.tsx","lineNumber":278,"sourceCode":"\n  useEffect(() => {\n    return () => {\n      if (visualHighlightTimerRef.current !== null)\n        window.clearTimeout(visualHighlightTimerRef.current)\n      if (jsonHighlightTimerRef.current !== null)\n        window.clearTimeout(jsonHighlightTimerRef.current)\n    }\n  }, [])\n\n  const loadConfig = useCallback(async () => {\n    setLoadingAction('load')\n    setError(null)\n    setSuccessMessage('')\n\n    try {\n      const response = await getConfigEditorConfigApi(serviceTarget, true)\n      if (!response || response.code !== 0 || !response.data?.config) {\n        throw new Error(getResponseMessage(response) || t('errors.loadFailed'))\n      }\n\n      const normalizedConfig = ensureRelayConfig(response.data.config, serviceTarget)\n      setConfig(normalizedConfig.config)\n      setOriginalConfig(normalizedConfig.config)\n      setJsonText(formatJsonConfig(normalizedConfig.config))\n      setVisualFocusRequest(null)\n      setJsonFocusRequest(null)\n      setHighlightedVisualPathKey('')\n      setHighlightedJsonPathKey('')\n      visualScrollTopRef.current = 0\n      setJsonScrollTop(0)\n      setInsertedRelayPath(normalizedConfig.insertedRelayPath)\n      setFormat(response.data.format)\n      setServiceStatus('running')\n      setHealthAttempts(0)\n    }\n    catch (loadError) {","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-web/src/app/layout/ConfigManagerDialog/index.tsx#L260-L296","documentation":"ConfigManagerDialog's load handler throws this fallback Error when the config editor API response is missing, returns a non-zero code, or lacks data.config, and the backend did not supply a more specific message. The error is caught locally and displayed via setError, aborting the config load and leaving the dialog without config data.","triggerScenarios":"Calling getConfigEditorConfigApi(serviceTarget, true) and receiving: undefined/null response, response.code !== 0, or response.data.config being null/undefined, with getResponseMessage(response) also empty.","commonSituations":"Relay/config-editor service not running or unreachable for the selected serviceTarget; auth token rejected by the internal API; backend returning an error envelope without a message field; network failure during dialog open.","solutions":["Check the relay/config-editor service for the selected serviceTarget is running and healthy","Verify the API token/credentials passed with the request are valid for the environment (aitoearn.cn vs aitoearn.ai)","Inspect the network tab for the actual HTTP status/body of the config request and fix the backend error message","Retry the load; if persistent, check backend logs for the config editor endpoint"],"exampleFix":"// before\nif (!response || response.code !== 0 || !response.data?.config) {\n  throw new Error(getResponseMessage(response) || t('errors.loadFailed'))\n}\n// after\nif (!response || response.code !== 0 || !response.data?.config) {\n  const reason = getResponseMessage(response)\n  setError(reason ? `${t('errors.loadFailed')}: ${reason}` : t('errors.loadFailed'))\n  return\n}","handlingStrategy":"try-catch","validationCode":"if (!serviceTarget) throw new Error('serviceTarget is required')","typeGuard":"function hasConfig(d: unknown): d is { config: Record<string, unknown> } {\n  return !!d && typeof d === 'object' && 'config' in d && d.config !== null\n}","tryCatchPattern":"try {\n  const response = await getConfigEditorConfigApi(serviceTarget, true)\n  if (!response || response.code !== 0 || !response.data?.config)\n    throw new Error(getResponseMessage(response) || 'config load failed')\n} catch (e) {\n  setError(e instanceof Error ? e.message : 'config load failed')\n}","preventionTips":["Check service health for the target before opening the dialog","Surface getResponseMessage(response) to the user instead of a generic fallback","Log response code and HTTP status when load fails","Validate the token for the correct environment before calling config APIs"],"tags":["config","api-response","network"],"backgroundTag":"api-nonzero-response-code","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}