multica-ai/multica · error

--%s-file %q: empty contents%s

Error message

--%s-file %q: empty contents%s

What it means

Thrown when --<prefix>-file points to a file that is read successfully but contains only whitespace. Empty contents are rejected as a probable mistake rather than interpreted as a clear; the message names the offending path and, where the flag supports it, hints to pass 'null' to clear. Purely client-side validation before the API call.

Source

Thrown at server/cmd/multica/cmd_agent.go:1421

			return nil, false, fmt.Errorf("read --%s-stdin: %w", prefix, err)
		}
		raw = string(buf)
		if strings.TrimSpace(raw) == "" {
			return nil, false, fmt.Errorf("--%s-stdin: empty input%s", prefix, clearHint)
		}
	case fromFile:
		if filePath == "" {
			return nil, false, fmt.Errorf("--%s-file: path must not be empty", prefix)
		}
		buf, err := os.ReadFile(filePath)
		if err != nil {
			// Filesystem errors may include the path but not the contents —
			// safe to surface via %w.
			return nil, false, fmt.Errorf("read --%s-file: %w", prefix, err)
		}
		raw = string(buf)
		if strings.TrimSpace(raw) == "" {
			return nil, false, fmt.Errorf("--%s-file %q: empty contents%s", prefix, filePath, clearHint)
		}
	}

	mc, err := parseMcpJSONObject("--"+prefix, raw, allowNull)
	if err != nil {
		return nil, false, err
	}
	return mc, true, nil
}

func strVal(m map[string]any, key string) string {
	v, ok := m[key]
	if !ok || v == nil {
		return ""
	}
	return fmt.Sprintf("%v", v)
}

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Put a real JSON object in the file: echo '{"servers": {}}' > cfg.json
  2. To clear the field, write the literal null into the file (echo null > cfg.json) when the flag allows it
  3. Validate files before use: test -s cfg.json && jq -e 'type == "object"' cfg.json

Example fix

# before
: > cfg.json && multica agent update <id> --mcp-config-file cfg.json
# after
printf '%s\n' '{"servers": {}}' > cfg.json && multica agent update <id> --mcp-config-file cfg.json
Defensive patterns

Strategy: validation

Validate before calling

test -s "$CFG_FILE" && jq -e 'type == "object"' "$CFG_FILE" >/dev/null || { echo "invalid config file" >&2; exit 1; }
multica agent update <id> --mcp-config-file "$CFG_FILE"

Prevention

When it happens

Trigger: `multica agent update <id> --mcp-config-file empty.json` where empty.json is 0 bytes or only newlines/spaces; a template render that produced no output; a truncated download.

Common situations: Helm/envsubst templates that render to nothing when a value is missing; an empty file committed by mistake; a partially written file after a crashed generator.

Related errors


AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15). Data as JSON: /api/errors/d25b5c59d533b1a8. Report an issue: GitHub.