{"record":{"id":"f004e986321a260d","repo":"alibaba/nacos","slug":"name-must-be-a-json-object","errorCode":null,"errorMessage":"${name} must be a JSON object","messagePattern":"(.+?) must be a JSON object","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"console-ui/src/pages/AI/agent-console-model.js","lineNumber":290,"sourceCode":"  });\n  const result = {\n    protocol: required(editor.customProtocol, 'protocol'),\n    protocolVersion: String(editor.customProtocolVersion || '').trim() || undefined,\n    descriptorMediaType: required(editor.customDescriptorMediaType, 'descriptorMediaType'),\n    nativeDescriptor,\n    endpointSourceOrder: sourceOrder(editor.endpointSourceMode),\n  };\n  if (declaredEndpoints.length > 0) result.declaredEndpoints = declaredEndpoints;\n  return result;\n}\n\nfunction serializeOptionalObject(value, name) {\n  if (!String(value || '').trim()) {\n    return undefined;\n  }\n  const parsed = parseJson(value, name);\n  if (!isObject(parsed)) {\n    throw new Error(`${name} must be a JSON object`);\n  }\n  return JSON.stringify(parsed);\n}\n\nfunction validateUniqueProtocols(callInterfaces) {\n  const protocols = new Set();\n  callInterfaces.forEach(callInterface => {\n    if (protocols.has(callInterface.protocol)) {\n      throw new Error(`protocol must be unique: ${callInterface.protocol}`);\n    }\n    protocols.add(callInterface.protocol);\n  });\n  return callInterfaces;\n}\n\nfunction serializeCallInterfaces(values, protocolEditors) {\n  const agentName = required(values.agentName, 'agentName');\n  const version = required(values.version, 'version');","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/console-ui/src/pages/AI/agent-console-model.js#L272-L308","documentation":"Thrown by serializeOptionalObject() in agent-console-model when an optional JSON text field (e.g. extensions) is non-empty and parses successfully but is not a JSON object (it is an array or primitive). Optional object fields are allowed to be blank, but when present they must be a single JSON object.","triggerScenarios":"Entering a JSON array or primitive into the 'extensions' field (or any other optional-object field) during initial agent draft creation, e.g. extensions = '[1,2]'.","commonSituations":"User treats an object field as a list field, or pastes an array where a map is required.","solutions":["Leave the field empty if you do not need it.","Enter a JSON object, e.g. {\"key\":\"value\"}.","Move list-shaped data to a field that accepts arrays (like tags)."],"exampleFix":"// before\n[1, 2, 3]\n\n// after\n{\"custom\":\"value\"}","handlingStrategy":"validation","validationCode":"function isValidOptionalObject(text) {\n  if (!String(text || '').trim()) return true;\n  let p;\n  try { p = JSON.parse(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  serializeOptionalObject(values.extensions, 'extensions');\n} catch (e) {\n  Message.error(e.message); // e.g. 'extensions must be a JSON object'\n  return;\n}","preventionTips":["Allow the field to be blank; only validate when non-empty.","Provide a JSON object template for optional-object fields.","Validate on blur for early feedback."],"tags":["validation","agent","extensions","json","frontend"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}