alibaba/nacos · error · Error

at least one protocol is required

Error message

at least one protocol is required

What it means

Thrown by serializeCallInterfaces when a protocolEditors array is explicitly provided but is empty. An agent must declare at least one callable interface; an empty list is meaningless. Providing undefined (omitting the argument) is allowed and uses the single-interface path.

Source

Thrown at console-ui-next/src/pages/newAgent/agent-console-model.ts:380

  if (!value.trim()) {
    return undefined;
  }
  const parsed = parseJson(value, name);
  if (parsed === null || Array.isArray(parsed) || typeof parsed !== 'object') {
    throw new Error(`${name} must be a JSON object`);
  }
  return JSON.stringify(parsed);
}

function serializeCallInterfaces(
  values: AgentEditorValues,
  protocolEditors?: StructuredProtocolEditorValues[],
): string {
  const agentName = required(values.agentName, 'agentName');
  const version = required(values.version, 'version');
  if (protocolEditors) {
    if (protocolEditors.length === 0) {
      throw new Error('at least one protocol is required');
    }
    return JSON.stringify(validateUniqueProtocols(protocolEditors.map(
      (editor) => buildStructuredCallInterface(agentName, version, editor),
    )));
  }
  if (values.protocolEditorKind !== 'raw') {
    return JSON.stringify([buildStructuredCallInterface(
      agentName,
      version,
      editorFromValues(values),
    )]);
  }
  const parsed = parseJson(
    required(values.callInterfaces, 'callInterfaces'),
    'callInterfaces',
  );
  if (!Array.isArray(parsed) || parsed.length === 0) {
    throw new Error('callInterfaces must be a non-empty JSON array');

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Add at least one protocol editor entry before submitting.
  2. If no protocols are intended, pass undefined (omit protocolEditors) rather than [] — though the single-interface fallback will still apply.
  3. Guard the submit handler to block empty protocol lists in the UI.

Example fix

// before
serializeCallInterfaces(values, []);

// after
serializeCallInterfaces(values, [structuredA2aEditor]);  // at least one
Defensive patterns

Strategy: validation

Validate before calling

function checkProtocolEditors(editors) {
  if (editors && editors.length === 0) throw new Error('Add at least one protocol');
}

Type guard

function hasAtLeastOne<T>(arr: T[] | undefined): boolean { return Array.isArray(arr) ? arr.length > 0 : true; }

Try / catch

try { serializeCallInterfaces(values, editors); } catch (e) {
  if (/at least one protocol is required/.test(e.message)) { toast.error('Add a protocol entry'); }
}

Prevention

When it happens

Trigger: The UI passes an empty array as protocolEditors, e.g. the user removed all protocol editor blocks but still submitted the form.

Common situations: Dynamic form where the user deletes every protocol row. State initialization bug producing [] instead of undefined.

Related errors


AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14). Data as JSON: /api/errors/b83be23cf270f70b. Report an issue: GitHub.