multica-ai/multica · error

add comment: %w

Error message

add comment: %w

What it means

After attachments (if any) upload, the CLI POSTs the comment body to /api/issues/{id}/comments. This error wraps that POST failing: server-side validation (e.g. invalid parent_id), auth, 4xx/5xx, or transport errors, chained with %w.

Source

Thrown at server/cmd/multica/cmd_issue.go:2015

	for _, att := range pending {
		id, uploadErr := client.UploadFile(ctx, att.data, att.path, issueID)
		if uploadErr != nil {
			return fmt.Errorf("upload attachment %s: %w", att.path, uploadErr)
		}
		attachmentIDs = append(attachmentIDs, id)
		fmt.Fprintf(os.Stderr, "Uploaded %s\n", att.path)
	}

	body := map[string]any{"content": content}
	if parentID, _ := cmd.Flags().GetString("parent"); parentID != "" {
		body["parent_id"] = parentID
	}
	if len(attachmentIDs) > 0 {
		body["attachment_ids"] = attachmentIDs
	}
	var result map[string]any
	if err := client.PostJSON(ctx, "/api/issues/"+issueID+"/comments", body, &result); err != nil {
		return fmt.Errorf("add comment: %w", err)
	}

	fmt.Fprintf(os.Stderr, "Comment added to issue %s.\n", issueRef.Display)

	output, _ := cmd.Flags().GetString("output")
	if output == "table" {
		return nil
	}
	return cli.PrintJSON(os.Stdout, result)
}

func runIssueCommentDelete(cmd *cobra.Command, args []string) error {
	client, err := newAPIClient(cmd)
	if err != nil {
		return err
	}

	ctx, cancel := cli.APIContext(context.Background())

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Check the chained cause: 4xx usually names the invalid field (e.g. parent_id).
  2. Re-verify the parent comment ID and the issue still exist.
  3. Retry after transient 5xx/network failures — note attachments may already be uploaded, so a retry can duplicate them.
  4. Inspect server logs for stack traces on persistent 5xx.
Defensive patterns

Strategy: try-catch

Validate before calling

# bash: validate the parent exists in this issue before posting a reply
if [[ -n "$PARENT" ]]; then
  multica issue comment list "$ISSUE" --output json | jq -e --arg p "$PARENT" 'any(.[]; .id == $p)' >/dev/null \
    || { echo "parent comment $PARENT not found" >&2; exit 2; }
fi

Try / catch

# bash: branch on the wrapped status
err=$(multica issue comment add "$ISSUE" --content "$BODY" 2>&1) || {
  case "$err" in
    *404*|*parent*) echo "bad parent/issue ref" >&2;;
    *401*|*403*) echo "auth/permission" >&2;;
    *) echo "transient, safe to retry (attachments may duplicate)" >&2;;
  esac
  exit 1;
}

Prevention

When it happens

Trigger: Passing a --parent comment ID that does not exist or belongs to another issue; server rejects empty/invalid content; auth expired between resolve and post; 5xx on the server.

Common situations: Replying to a deleted parent comment; race where the issue was closed/deleted after resolution; server middleware rejecting the payload.

Related errors


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