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.
Solutions
- Fix the JSON config so it passes backend schema validation (check required fields per serviceTarget)
- Confirm the config editor service for serviceTarget is reachable
- Check auth/token validity for the environment
- 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
- Client-side JSON.parse the editor text before sending to validate
- Show the backend's validation message, not just a generic failure
- Keep config schema docs per serviceTarget up to date
- Handle null/undefined API responses explicitly
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
- errors.loadFailed
- errors.saveFailed
- 无效的视频上传结果,缺少视频ID
- InvalidModel
- ResponseCode.ConfigEditorValidationFailed
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/0aac5f36da31346d.
Report an issue: GitHub.
Appendix: 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)