{"record":{"id":"444a95d00ec7b839","repo":"alibaba/nacos","slug":"callinterfaces-must-be-a-non-empty-json-array-444a95","errorCode":null,"errorMessage":"callInterfaces must be a non-empty JSON array","messagePattern":"callInterfaces must be a non-empty JSON array","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"console-ui-next/src/pages/newAgent/agent-console-model.ts","lineNumber":398,"sourceCode":"      throw new Error('at least one protocol is required');\n    }\n    return JSON.stringify(validateUniqueProtocols(protocolEditors.map(\n      (editor) => buildStructuredCallInterface(agentName, version, editor),\n    )));\n  }\n  if (values.protocolEditorKind !== 'raw') {\n    return JSON.stringify([buildStructuredCallInterface(\n      agentName,\n      version,\n      editorFromValues(values),\n    )]);\n  }\n  const parsed = parseJson(\n    required(values.callInterfaces, 'callInterfaces'),\n    'callInterfaces',\n  );\n  if (!Array.isArray(parsed) || parsed.length === 0) {\n    throw new Error('callInterfaces must be a non-empty JSON array');\n  }\n  return JSON.stringify(parsed);\n}\n\nfunction serializeProvider(values: AgentEditorValues): string | undefined {\n  const name = values.providerName.trim();\n  const url = values.providerUrl.trim();\n  if (!name && !url) {\n    return undefined;\n  }\n  if (!name) {\n    throw new Error('providerName is required when providerUrl is set');\n  }\n  return JSON.stringify(url ? { name, url } : { name });\n}\n\nfunction serializeTags(value: string): string | undefined {\n  const tags = value.split(',').map((item) => item.trim()).filter(Boolean);","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/console-ui-next/src/pages/newAgent/agent-console-model.ts#L380-L416","documentation":"Thrown in the raw-mode branch of serializeCallInterfaces: the user-supplied callInterfaces JSON parsed but is not a non-empty array. Raw mode requires the value to be a JSON array of interface objects; an object, primitive, null, or empty array is rejected.","triggerScenarios":"User enters a single object '{...}' instead of an array '[{...}]', an empty array '[]', or a non-array value in the raw callInterfaces textarea.","commonSituations":"Hand-authoring raw JSON and forgetting the outer array. Pasting a single interface object. Empty array from cleared input.","solutions":["Wrap the interface(s) in a JSON array: '[{...}]'.","Ensure the array has at least one element.","Use the structured editor instead of raw mode if hand-authoring arrays is error-prone."],"exampleFix":"// before\n{\"protocol\":\"A2A\",\"url\":\"https://a.example.com\"}\n\n// after\n[{\"protocol\":\"A2A\",\"url\":\"https://a.example.com\"}]","handlingStrategy":"validation","validationCode":"function checkRawCallInterfaces(text) {\n  const parsed = JSON.parse(text);\n  if (!Array.isArray(parsed) || parsed.length === 0) throw new Error('callInterfaces must be a non-empty array');\n  return parsed;\n}","typeGuard":"function isNonEmptyArray(v: unknown): v is unknown[] { return Array.isArray(v) && v.length > 0; }","tryCatchPattern":"try { serializeCallInterfaces(values); } catch (e) {\n  if (/non-empty JSON array/.test(e.message)) { toast.error('Wrap interfaces in a non-empty JSON array'); }\n}","preventionTips":["Wrap interfaces in []","Ensure at least one element","Use structured editor if raw JSON is error-prone"],"tags":["validation","callinterfaces","json","array","agent"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}