{"record":{"id":"e977ac2f2babedfa","repo":"alibaba/nacos","slug":"name-is-required-e977ac","errorCode":null,"errorMessage":"${name} is required","messagePattern":"(.+?) is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"console-ui-next/src/pages/newAgent/agent-console-model.ts","lineNumber":106,"sourceCode":"  status: 'enable' | 'disable';\n  protocolEditorKind: ProtocolEditorKind;\n  agentCard: string;\n  customProtocol: string;\n  customProtocolVersion: string;\n  customDescriptorMediaType: string;\n  customNativeDescriptor: string;\n  endpointSourceMode: EndpointSourceMode;\n  declaredEndpoints: DeclaredEndpointEditorValue[];\n  callInterfaces: string;\n  basedOnVersion: string;\n  author: string;\n  changeDescription: string;\n}\n\nfunction required(value: string, name: string): string {\n  const result = value.trim();\n  if (!result) {\n    throw new Error(`${name} is required`);\n  }\n  return result;\n}\n\nfunction parseJson(value: string, name: string): unknown {\n  try {\n    return JSON.parse(value);\n  } catch {\n    throw new Error(`${name} must be valid JSON`);\n  }\n}\n\nfunction parseAgentCardJson(value: string): unknown {\n  const withoutTrailingCommas = value.replace(\n    /(\"(?:\\\\.|[^\"\\\\])*\")|,\\s*([}\\]])/g,\n    (match, quoted, closing) => quoted || closing || match,\n  );\n  return parseJson(withoutTrailingCommas, 'agentCard');","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/console-ui-next/src/pages/newAgent/agent-console-model.ts#L88-L124","documentation":"Generic required-field validator in the new-agent console model. It trims the input and throws if the result is empty. It is reused by many callers with a `name` argument, so the message is parameterized (e.g. 'agentName is required', 'transport is required', 'version is required').","triggerScenarios":"The user submits the new-agent form with a required text field left blank or containing only whitespace. Called for agentName, version, transport, Endpoint uri, nativeDescriptor, descriptorMediaType, agentCard, callInterfaces, and providerName.","commonSituations":"Submitting a draft before filling required fields. A field auto-filled from a disabled control that returned empty. Whitespace-only input from copy-paste.","solutions":["Identify which field is named in the message and provide a non-empty value.","Add client-side required-field indicators so the user sees the gap before submit.","Strip stray whitespace on blur to avoid whitespace-only submissions."],"exampleFix":"// before\nvalues.agentName = '   ';\n\n// after\nvalues.agentName = 'my-agent';","handlingStrategy":"validation","validationCode":"function ensureRequired(value, name) {\n  if (!value || !value.trim()) { throw new Error(`${name} is required`); }\n  return value.trim();\n}","typeGuard":"function isNonEmptyString(v: unknown): v is string {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try { serializeCallInterfaces(values); } catch (e) {\n  if (/is required/.test(e.message)) { markFieldError(e.message); }\n}","preventionTips":["Mark required fields visually","Validate on blur","Trim whitespace on input"],"tags":["validation","required-field","form","agent"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}