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

  1. Validate the JSON in an external linter before pasting.
  2. Use double quotes for all keys and string values.
  3. 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

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


AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14). Data as JSON: /api/errors/2efbf1b746579534. Report an issue: GitHub.