{"record":{"id":"5cdc09cd8af45c6f","repo":"alibaba/nacos","slug":"providername-is-required-when-providerurl-is-set-5cdc09","errorCode":null,"errorMessage":"providerName is required when providerUrl is set","messagePattern":"providerName is required when providerUrl is set","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"console-ui-next/src/pages/newAgent/agent-console-model.ts","lineNumber":410,"sourceCode":"  }\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);\n  return tags.length > 0 ? JSON.stringify(tags) : undefined;\n}\n\nexport function buildDraftCreateData(\n  namespaceId: string,\n  values: AgentEditorValues,\n  initial: boolean,\n  contentMode: DraftContentMode,\n  protocolEditors?: StructuredProtocolEditorValues[],\n): AgentDraftCreateData {\n  const result: AgentDraftCreateData = {\n    namespaceId,","sourceCodeStart":392,"sourceCodeEnd":428,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/console-ui-next/src/pages/newAgent/agent-console-model.ts#L392-L428","documentation":"Thrown by serializeProvider when a providerUrl is set but providerName is empty. The provider object requires at least a name; a URL alone is meaningless (the backend would not know whom the URL belongs to). If both are empty, the field is omitted entirely (returns undefined) — only the half-filled case errors.","triggerScenarios":"User fills the provider URL field but leaves the provider name blank, or vice-versa intentionally but only name is given (name-only is allowed and produces {name}).","commonSituations":"Form has two adjacent fields; user fills one. Copy-paste lands only in the URL field. Name field disabled or hidden by a conditional.","solutions":["Provide a providerName whenever you set a providerUrl.","If no provider is needed, clear both fields.","Add a client-side rule linking the two fields (disable URL until name is set)."],"exampleFix":"// before\nproviderName = ''\nproviderUrl = 'https://vendor.example.com'\n\n// after\nproviderName = 'Vendor Inc'\nproviderUrl = 'https://vendor.example.com'","handlingStrategy":"validation","validationCode":"function checkProvider(name, url) {\n  if (url && !name) throw new Error('providerName required when providerUrl is set');\n}","typeGuard":"function isProviderComplete(name: string, url: string): boolean {\n  return (name && url) || (!name && !url) || (name && !url);\n}","tryCatchPattern":"try { serializeProvider(values); } catch (e) {\n  if (/providerName is required/.test(e.message)) { toast.error('Enter a provider name'); }\n}","preventionTips":["Link the two fields in the UI","Disable URL field until name is set","Clear both fields if no provider needed"],"tags":["validation","provider","required-field","agent"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}