{"record":{"id":"4ba93f7db2313704","repo":"alibaba/nacos","slug":"name-is-required","errorCode":null,"errorMessage":"${name} is required","messagePattern":"(.+?) is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"console-ui/src/pages/AI/agent-console-model.js","lineNumber":56,"sourceCode":"export const DEFAULT_CALL_INTERFACES = JSON.stringify(\n  [\n    {\n      protocol: 'custom',\n      protocolVersion: '1.0.0',\n      descriptorMediaType: 'application/json',\n      nativeDescriptor: {},\n      endpointSourceOrder: ['RUNTIME', 'DECLARED'],\n      declaredEndpoints: [],\n    },\n  ],\n  null,\n  2\n);\n\nfunction required(value, name) {\n  const result = String(value || '').trim();\n  if (!result) {\n    throw new Error(`${name} is required`);\n  }\n  return result;\n}\n\nfunction parseJson(value, name) {\n  try {\n    return JSON.parse(value);\n  } catch (e) {\n    throw new Error(`${name} must be valid JSON`);\n  }\n}\n\nfunction parseAgentCardJson(value) {\n  const withoutTrailingCommas = value.replace(\n    /(\"(?:\\\\.|[^\"\\\\])*\")|,\\s*([}\\]])/g,\n    (match, quoted, closing) => quoted || closing || match\n  );\n  return parseJson(withoutTrailingCommas, 'agentCard');","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/console-ui/src/pages/AI/agent-console-model.js#L38-L74","documentation":"Thrown by the agent-console-model required() helper when a value is null, undefined, empty, or whitespace-only after trimming. This is the shared guard for mandatory string fields across agent draft creation, A2A card projection, and call-interface serialization. The error embeds the field name (e.g. 'agentName', 'version', 'transport', 'AgentCard name').","triggerScenarios":"Submitting an agent form with a blank required field: agentName, version, basedOnVersion, transport, AgentCard interface url, AgentCard interface protocolVersion, callInterfaces, or agentCard text.","commonSituations":"User leaves the agent name or version empty, pastes an AgentCard JSON missing the 'name' field, or a structured protocol editor with an empty transport.","solutions":["Read the field name in the message and fill in that required field.","For AgentCard projection, ensure the JSON includes non-empty 'name' and 'version' (or pass a fallback version).","For transport, ensure a protocol binding like 'HTTP' or 'GRPC' is selected."],"exampleFix":"// before\nvalues.agentName = '';\n\n// after\nvalues.agentName = 'my-agent';","handlingStrategy":"validation","validationCode":"function assertRequired(value, name) {\n  const result = String(value || '').trim();\n  if (!result) throw new Error(`${name} is required`);\n  return result;\n}","typeGuard":"function isNonEmptyString(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  buildDraftCreateData(namespaceId, values, initial, contentMode, protocolEditors);\n} catch (e) {\n  Message.error(e.message); // e.g. 'agentName is required'\n  return;\n}","preventionTips":["Mark required fields in the UI with a visible asterisk and disable submit until filled.","Run required() checks on blur for immediate feedback.","Seed default values (e.g. version '1.0.0') to reduce blank submissions."],"tags":["validation","agent","required-field","frontend"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}