can1357/oh-my-pi · error · GitHubError

proxy returned malformed review_comment payload

Error message

proxy returned malformed review_comment payload

What it means

GitHubError(500) raised by _review_comment_from when a PR review-comment payload from the proxy is not a JSON object. Each review comment must be a dict; a non-dict element aborts listing review comments for the PR.

Source

Thrown at python/robomp/src/proxy_client.py:684

        author=str(data.get("author") or ""),
        body=str(data.get("body") or ""),
        created_at=str(data.get("created_at") or ""),
    )


def _reaction_from(data: Any) -> ReactionInfo:
    if not isinstance(data, dict):
        raise GitHubError(500, "proxy returned malformed reaction payload")
    return ReactionInfo(
        content=str(data.get("content") or ""),
        user_login=str(data.get("user_login") or ""),
        user_type=str(data.get("user_type") or ""),
    )


def _review_comment_from(data: Any) -> ReviewCommentInfo:
    if not isinstance(data, dict):
        raise GitHubError(500, "proxy returned malformed review_comment payload")
    line = data.get("line")
    return ReviewCommentInfo(
        id=int(data.get("id") or 0),
        author=str(data.get("author") or ""),
        body=str(data.get("body") or ""),
        path=str(data.get("path") or ""),
        line=line if isinstance(line, int) else None,
        created_at=str(data.get("created_at") or ""),
    )


def _pr_review_from(data: Any) -> PullRequestReviewInfo:
    if not isinstance(data, dict):
        raise GitHubError(500, "proxy returned malformed pr_review payload")
    return PullRequestReviewInfo(
        id=int(data.get("id") or 0),
        author=str(data.get("author") or ""),
        body=str(data.get("body") or ""),

View on GitHub (pinned to 9690622007)

Solutions

  1. Inspect the raw review-comments response from the proxy to identify the malformed element.
  2. Check proxy version compatibility; redeploy/upgrade the proxy to match the client schema.
  3. Check proxy logs for upstream GitHub errors on the review-comments endpoint being passed through unshaped.
  4. Retry the call; if persistent, fall back to fetching review comments through list_pr_reviews and client-side assembly.
  5. Report the malformed element (with its position in the array) to the proxy maintainers.

Example fix

# before
comments = client.list_review_comments("org/repo", pr_number)  # GitHubError 500

# after
try:
    comments = client.list_review_comments("org/repo", pr_number)
except GitHubError as e:
    if e.status == 500:
        comments = []  # proceed without inline review comments
    else:
        raise
Defensive patterns

Strategy: try-catch

Validate before calling

raw = resp.json()
items = raw if isinstance(raw, list) else []
if any(not isinstance(x, dict) for x in items):
    raise RuntimeError("proxy returned non-object review-comment entries")

Type guard

def is_review_comment(data: object) -> bool:
    return isinstance(data, dict) and "id" in data and "path" in data

Try / catch

try:
    comments = client.list_review_comments("org/repo", pr)
except GitHubError as e:
    if e.status == 500 and "malformed review_comment payload" in str(e):
        comments = []  # proceed without inline comments
    else:
        raise

Prevention

When it happens

Trigger: Calling list_review_comments() when the proxy returns a reviews/comments array containing null, strings, or other scalars instead of review-comment objects.

Common situations: Proxy emitting null for review comments on files that were deleted in a force-push; stale proxy version with a different review-comment envelope; gateway rewriting bodies; upstream GitHub error leaking through as a scalar.

Understand the failure class

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/0a84c19dda0f6e3a. Report an issue: GitHub.