multica-ai/multica · error

read --%s-file: %w

Error message

read --%s-file: %w

What it means

Thrown when os.ReadFile fails for the path given to --<prefix>-file. The filesystem error is wrapped with %w, so the message includes the underlying cause: file does not exist, permission denied, or a path component is not a directory. The CLI's comment notes filesystem errors contain the path but not the contents, so surfacing them is safe.

Source

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

		raw, _ = cmd.Flags().GetString(prefix)
	case fromStdin:
		buf, err := io.ReadAll(cmd.InOrStdin())
		if err != nil {
			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 ""

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Verify the path exists and is readable: ls -l <path>, and that you are in the expected working directory
  2. Use an absolute path for the file flag to remove cwd ambiguity
  3. Fix permissions (chmod/chown) if the error is permission denied
  4. If the file was never created, write the config first or pass it inline via --<prefix>

Example fix

# before
multica agent update <id> --mcp-config-file cfg/mcp.json   # run from wrong cwd
# after
multica agent update <id> --mcp-config-file "$(pwd)/cfg/mcp.json"
Defensive patterns

Strategy: validation

Validate before calling

test -r "$CFG_FILE" || { echo "missing or unreadable: $CFG_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 ./missing.json` (ENOENT); a file with mode 600 owned by another user (EACCES); a path like /etc/passwd/dir where a component is a file (ENOTDIR).

Common situations: Running the CLI from a different working directory than assumed with relative paths; deploying to an environment where the config file was not mounted into the container; typos in the path; file permissions differing between dev and prod users.

Related errors


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