{"record":{"id":"184111bd12f7516d","repo":"alibaba/nacos","slug":"agentcard-must-be-a-json-object","errorCode":null,"errorMessage":"agentCard must be a JSON object","messagePattern":"agentCard must be a JSON object","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"console-ui/src/pages/AI/agent-console-model.js","lineNumber":165,"sourceCode":"  const url = required(optionalString(value.url) || '', 'AgentCard interface url');\n  const protocolBinding = validateTransport(\n    optionalString(value.protocolBinding) ||\n      optionalString(value.transport) ||\n      fallbackTransport ||\n      ''\n  );\n  endpointKey(url, protocolBinding);\n  const protocolVersion = required(\n    optionalString(value.protocolVersion) || fallbackVersion || '',\n    'AgentCard interface protocolVersion'\n  );\n  return { ...value, url, transport: protocolBinding, protocolBinding, protocolVersion };\n}\n\nfunction normalizeA2aAgentCard(agentName, version, text) {\n  const parsed = parseAgentCardJson(required(text, 'agentCard'));\n  if (!isObject(parsed)) {\n    throw new Error('agentCard must be a JSON object');\n  }\n  const card = { ...parsed, name: agentName, version };\n  const topProtocolVersion = optionalString(card.protocolVersion);\n  const preferredTransport = optionalString(card.preferredTransport);\n  let interfaces;\n  if (Array.isArray(card.supportedInterfaces) && card.supportedInterfaces.length > 0) {\n    interfaces = card.supportedInterfaces.map(item => {\n      return normalizeA2aInterface(item, preferredTransport, topProtocolVersion);\n    });\n  } else {\n    const preferred = normalizeA2aInterface(\n      {\n        url: card.url,\n        protocolBinding: preferredTransport,\n        protocolVersion: topProtocolVersion,\n      },\n      undefined,\n      undefined","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/console-ui/src/pages/AI/agent-console-model.js#L147-L183","documentation":"Thrown by normalizeA2aAgentCard() in agent-console-model when the parsed AgentCard text is valid JSON but is not a plain object (e.g., it is an array or a primitive). The A2A AgentCard must be a single JSON object. This is distinct from a JSON syntax error (987) and from the projection-time check (999).","triggerScenarios":"Pasting a JSON array or a bare string/number as the agentCard value during structured A2A protocol editing, e.g. agentCard = '[]' or agentCard = '\"hello\"'.","commonSituations":"User wraps the card in an array, or pastes only a URL string where the full card object is expected.","solutions":["Ensure the agentCard text is a single JSON object delimited by { }.","Start from DEFAULT_AGENT_CARD as a template.","Remove outer array brackets or quotes around the object."],"exampleFix":"// before\n[{\"name\":\"x\",\"version\":\"1\"}]\n\n// after\n{\"name\":\"x\",\"version\":\"1\"}","handlingStrategy":"type-guard","validationCode":"function parsedCardIsObject(text) {\n  let p;\n  try { p = parseAgentCardJson(text); } catch { return false; }\n  return p !== null && !Array.isArray(p) && typeof p === 'object';\n}","typeGuard":"function isPlainObject(v) {\n  return v !== null && !Array.isArray(v) && typeof v === 'object';\n}","tryCatchPattern":"try {\n  normalizeA2aAgentCard(agentName, version, text);\n} catch (e) {\n  Message.error(e.message); // 'agentCard must be a JSON object'\n  return;\n}","preventionTips":["Start agentCard editing from DEFAULT_AGENT_CARD.","Validate the parsed card is an object on blur.","Reject array/primitive input at the editor boundary."],"tags":["validation","agent","a2a","agent-card","frontend"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}