alibaba/nacos · warning · Error
${name} must be valid JSON
Error message
${name} must be valid JSON What it means
Thrown by the agent-console-model parseJson() helper when JSON.parse fails on a user-supplied text value. This guards every JSON text field (agentCard, callInterfaces, extensions, etc.). The error embeds the field name so you know which input is invalid.
Source
Thrown at console-ui/src/pages/AI/agent-console-model.js:65
},
],
null,
2
);
function required(value, name) {
const result = String(value || '').trim();
if (!result) {
throw new Error(`${name} is required`);
}
return result;
}
function parseJson(value, name) {
try {
return JSON.parse(value);
} catch (e) {
throw new Error(`${name} must be valid JSON`);
}
}
function parseAgentCardJson(value) {
const withoutTrailingCommas = value.replace(
/("(?:\\.|[^"\\])*")|,\s*([}\]])/g,
(match, quoted, closing) => quoted || closing || match
);
return parseJson(withoutTrailingCommas, 'agentCard');
}
function isObject(value) {
return value !== null && !Array.isArray(value) && typeof value === 'object';
}
function optionalString(value) {
return typeof value === 'string' && value.trim() ? value.trim() : undefined;
}View on GitHub (pinned to 9b989acdf1)
Solutions
- Validate the JSON in an external linter before pasting.
- Use double quotes for all keys and string values.
- If the only issue is trailing commas, they are already tolerated; look for a different syntax error.
Example fix
// before
{name: 'x',}
// after
{"name":"x"} Defensive patterns
Strategy: validation
Validate before calling
function isValidJson(text) {
try { JSON.parse(text); return true; } catch { return false; }
} Try / catch
try {
parseJson(values.extensions, 'extensions');
} catch (e) {
Message.error(e.message); // e.g. 'extensions must be valid JSON'
return;
} Prevention
- Provide a JSON editor with syntax highlighting and live validation.
- Validate JSON on blur, not only on submit.
- Offer a 'format JSON' button to catch errors early.
When it happens
Trigger: Entering malformed JSON in any agent text field: missing quotes, trailing characters, unbalanced braces. Note parseAgentCardJson tolerates trailing commas before parsing, so plain trailing commas alone will not trigger this.
Common situations: Hand-editing the AgentCard or callInterfaces JSON and introducing a syntax error; pasting JSON from a source that uses single quotes or comments.
Related errors
- Labels must be a JSON object
- ${name} must be a JSON object
- callInterfaces must be a non-empty JSON array
- The latest label is managed by the server
- ${name} is required
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/2efbf1b746579534.
Report an issue: GitHub.