yikart/AiToEarn · error · Error

errors.validateFailed

Error message

errors.validateFailed

What it means

ConfigManagerDialog's validate flow throws this fallback Error when validateConfigEditorConfigApi responds with a non-zero code or an empty/undefined response and the backend gave no message. The thrown error is caught and shown via setError, so the config is not marked valid and save is blocked.

Source

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

    if (parsedConfig)
      setConfig(parsedConfig)
    return parsedConfig
  }, [config, editMode, parseJsonText])

  const validateConfig = useCallback(async (action: LoadingAction = 'validate', configOverride?: Record<string, unknown>) => {
    const editableConfig = configOverride ?? getEditableConfig()
    if (!editableConfig)
      return false
    const submittableConfig = stripInsertedRelayPlaceholder(editableConfig, insertedRelayPath, serviceTarget)

    setLoadingAction(action)
    setError(null)
    setSuccessMessage('')

    try {
      const response = await validateConfigEditorConfigApi({ config: submittableConfig }, serviceTarget, true)
      if (!response || response.code !== 0) {
        throw new Error(getResponseMessage(response) || t('errors.validateFailed'))
      }
      if (action === 'validate') {
        setSuccessMessage(t('messages.validateSuccess'))
        toast.success(t('messages.validateSuccess'))
      }
      return true
    }
    catch (validateError) {
      setError({ title: t('errors.validateFailed'), description: getErrorMessage(validateError) })
      return false
    }
    finally {
      if (action === 'validate')
        setLoadingAction(null)
    }
  }, [getEditableConfig, insertedRelayPath, serviceTarget, t])

  const saveConfig = useCallback(async (action: LoadingAction = 'save') => {

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Fix the JSON config so it passes backend schema validation (check required fields per serviceTarget)
  2. Confirm the config editor service for serviceTarget is reachable
  3. Check auth/token validity for the environment
  4. Inspect backend logs to see which validation rule failed and why no message was returned

Example fix

// before
if (!response || response.code !== 0) {
  throw new Error(getResponseMessage(response) || t('errors.validateFailed'))
}
// after
if (!response || response.code !== 0) {
  setError(getResponseMessage(response) || t('errors.validateFailed'))
  return false
}
Defensive patterns

Strategy: validation

Validate before calling

function isSubmittable(config: unknown): boolean {
  try { JSON.stringify(config); return config !== null && typeof config === 'object' } catch { return false }
}

Type guard

function isApiEnvelope(r: unknown): r is { code: number; message?: string; data?: unknown } {
  return !!r && typeof r === 'object' && 'code' in r && typeof (r as any).code === 'number'
}

Try / catch

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

Prevention

When it happens

Trigger: Calling validateConfigEditorConfigApi({ config: submittableConfig }, serviceTarget, true) and receiving null/undefined response or response.code !== 0 with no message.

Common situations: Submitting malformed JSON config the backend validator rejects; serviceTarget service unavailable; stale auth; backend validation failing without a user-facing message.

Related errors


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