yikart/AiToEarn · error · Error

errors.loadFailed

Error message

errors.loadFailed

What it means

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.

Source

Thrown at project/aitoearn-web/src/app/layout/ConfigManagerDialog/index.tsx:278

  useEffect(() => {
    return () => {
      if (visualHighlightTimerRef.current !== null)
        window.clearTimeout(visualHighlightTimerRef.current)
      if (jsonHighlightTimerRef.current !== null)
        window.clearTimeout(jsonHighlightTimerRef.current)
    }
  }, [])

  const loadConfig = useCallback(async () => {
    setLoadingAction('load')
    setError(null)
    setSuccessMessage('')

    try {
      const response = await getConfigEditorConfigApi(serviceTarget, true)
      if (!response || response.code !== 0 || !response.data?.config) {
        throw new Error(getResponseMessage(response) || t('errors.loadFailed'))
      }

      const normalizedConfig = ensureRelayConfig(response.data.config, serviceTarget)
      setConfig(normalizedConfig.config)
      setOriginalConfig(normalizedConfig.config)
      setJsonText(formatJsonConfig(normalizedConfig.config))
      setVisualFocusRequest(null)
      setJsonFocusRequest(null)
      setHighlightedVisualPathKey('')
      setHighlightedJsonPathKey('')
      visualScrollTopRef.current = 0
      setJsonScrollTop(0)
      setInsertedRelayPath(normalizedConfig.insertedRelayPath)
      setFormat(response.data.format)
      setServiceStatus('running')
      setHealthAttempts(0)
    }
    catch (loadError) {

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Check the relay/config-editor service for the selected serviceTarget is running and healthy
  2. Verify the API token/credentials passed with the request are valid for the environment (aitoearn.cn vs aitoearn.ai)
  3. Inspect the network tab for the actual HTTP status/body of the config request and fix the backend error message
  4. Retry the load; if persistent, check backend logs for the config editor endpoint

Example fix

// before
if (!response || response.code !== 0 || !response.data?.config) {
  throw new Error(getResponseMessage(response) || t('errors.loadFailed'))
}
// after
if (!response || response.code !== 0 || !response.data?.config) {
  const reason = getResponseMessage(response)
  setError(reason ? `${t('errors.loadFailed')}: ${reason}` : t('errors.loadFailed'))
  return
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!serviceTarget) throw new Error('serviceTarget is required')

Type guard

function hasConfig(d: unknown): d is { config: Record<string, unknown> } {
  return !!d && typeof d === 'object' && 'config' in d && d.config !== null
}

Try / catch

try {
  const response = await getConfigEditorConfigApi(serviceTarget, true)
  if (!response || response.code !== 0 || !response.data?.config)
    throw new Error(getResponseMessage(response) || 'config load failed')
} catch (e) {
  setError(e instanceof Error ? e.message : 'config load failed')
}

Prevention

When it happens

Trigger: Calling getConfigEditorConfigApi(serviceTarget, true) and receiving: undefined/null response, response.code !== 0, or response.data.config being null/undefined, with getResponseMessage(response) also empty.

Common situations: 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.

Related errors


AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31). Data as JSON: /api/errors/8536ea577d6b49eb. Report an issue: GitHub.