Skip to content

Normalize malformed response failures across the remaining typed parsers - #352

Merged
allenhutchison merged 5 commits into
mainfrom
claude/project-thread-r1mf6t-cli-310-parsers
Nov 23, 2026
Merged

allenhutchison merged 5 commits into
mainfrom
claude/project-thread-r1mf6t-cli-310-parsers

Conversation

@allenhutchison

@allenhutchison allenhutchison commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Human overview

Finishes the parser audit from #348: the remaining typed parsers in api_client.py now turn a malformed 200 into an ApiError (status 200) that names the field or shape, instead of leaking KeyError/TypeError. Every list fails whole on a bad row (no silent partial lists); opt-in skip-and-count with a visible marker is follow-up #353. Fixes #310.

AI reviewer

Details for agents: what the diff does, invariants, verification, checklist

What changed. Helpers _wire_field, _wire_list, _wire_rows (fail-whole) and _wire_opt (optional field: default when missing or null, malformed on any other type, bool included) beside #348's _wire_row/_wire_get; _wire_get with no types is a presence check. Converted: todos and room todos, skills and room skills, device start/poll and whoami (shared _whoami_from), group list/summary/topic/message/card/roster/app tile, artifact list/detail/create/edit, note comments and threads, image details, blog publish/withdraw, chat send, scheduled-task thread, trajectory list, upload, and the .json()["key"] accessors. The generic "malformed response" raises now name the response.

Fail-whole everywhere. Skip-and-count was removed after VR round 1: every list, including the ones the TUI polls, raises the malformed ApiError on one bad row, which was already the behaviour at the base. Room todos keep their existing tolerance for non-object rooms/items, but a malformed todo object or a wrong-typed room name fails the read (the TUI falls back to your own todos). Malformed-response errors carry an empty body, so a device-poll PAT never reaches it. Only ApiError is caught, never Exception.

Compat. Optional fields keep defaults (merged_from, formats, person_id, toolsets, labels, topics, features, ...). last_activity_at stays nullable.

Not done. A non-JSON 200 body still raises the JSON decode ValueError from resp.json(). Raw-dict passthrough endpoints only get a top-level object/list check. View modules (feed, brief, following) were already defensive and are unchanged. Opt-in skip-and-count for the polled lists, with a visible partial marker, is #353.

Verification (actual). ruff format --check clean, ruff check clean, ty check src/pepper_cli/ clean, pytest -n auto --cov: 3881 passed, 2 skipped, 95% coverage (floor 88), at b5fc6e3. New tests: tests/test_api_client_malformed_parsers.py; one assertion in test_api_client_room_skills.py now checks the malformed response prefix.

Checklist (repo-specific)

  • uv run ruff format --check and uv run ruff check clean (no new lint ignores)
  • uv run ty check src/pepper_cli/ clean
  • uv run pytest passes; coverage floor in .claude/maintainerd.json not lowered
  • Server-contract changes: /api/v1 usage stays additive-only, # MIRROR: comments updated, unknown fields and frames still tolerated (contract test green, no mirrored dataclass changed)
  • No token or credential is logged, printed, or put in a fixture
  • README and the bundled SKILL.md updated: not needed, no command or output changed
  • Help: help/cli.md not user-facing because only error handling on malformed responses changed

Fixes #310


Generated by Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no new actionable issues were found.

Summary

The PR makes malformed successful replies raise ApiError with a field or shape name across the remaining typed parsers.

  • Typed lists now stop when a response row is malformed.
  • Typed responses name malformed fields instead of leaking parser errors.
  • Raw API responses now report malformed shapes without echoing their contents.

Reviews (7) · Last reviewed commit: "Merge main (blog commands #337) into cli..." · Reviewed by Greptile

Todos, room todos, skills, groups, rooms topics/messages/roster/app tiles, artifacts,
note comments, image details, blog, chat send, sign-in and whoami parsers now raise
ApiError (status 200) naming the shape or field instead of leaking KeyError/TypeError.
Lists a poller reads (groups, group messages, artifacts, todos) skip and count a bad
row; other lists fail whole. Optional fields keep their defaults.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QNDehAurHo1CzCzisi6nYx
@vycari-review

vycari-review Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Vycari Review

Round 5 on 2377ebf. The verdict is the Vycari Review check run, and each open finding is an inline thread. Reply on every P0 and P1 thread: Fixed in <sha>, or Disputed: with a reason. P2s are the author's call: fix one, or reply Deferred: #<issue> (the PR's one follow-up issue) or Declined: with a reason, and VR stops re-raising it. From round 2 on, VR raises no new P2s: it checks the fixes and looks for P0s and P1s.

Open: P0 0 · P1 0 · P2 0 · disputed 0 · confirmed fixed 0 · withdrawn 0

Hand-off: Covered: no Greptile round needed (Greptile's passing review of 2377ebf still covers this head).

No open findings this round.

P2s, judge's notes and closed findings

Judge's notes

Capped: hunter:cross-file-contract (partial output kept). One candidate survived: a sent room message that the server stored could show as failed if the reply has a null field. I dropped it, because it needs the server to break its own contract, and turning a malformed reply into an error is what this PR is meant to do. The blog changes since the hand-off are simple pass-through parsers, and no P0 or P1 findings remain.

@allenhutchison

Copy link
Copy Markdown
Contributor Author

Deferred gaps (a non-JSON 200 body, the raw-dict passthroughs, and showing skip counts in the TUI) are filed as #353.


Generated by Claude Code

Comment thread src/pepper_cli/api_client.py Resolved
Comment thread src/pepper_cli/api_client.py Resolved
Comment thread src/pepper_cli/tui/poller.py Resolved
Comment thread src/pepper_cli/api_client.py Resolved
… of errors

Every list parser is strict again: a malformed group, group message,
artifact or todo row fails the whole read with ApiError(200), as it did
before this PR, so the rail never commits an ETag for a partial list, a
note or room lookup cannot miss a row, and a stale-message refresh is
retried. The unread `skipped` fields, TodoList, ArtifactListPage and the
skip_bad_rows flag go with it. Room todos keep their older tolerance for
non-object rooms and items. Showing partial lists is #353.

_malformed no longer puts the raw value in ApiError.body: a device-poll
body can carry the approved token.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QNDehAurHo1CzCzisi6nYx
@allenhutchison

Copy link
Copy Markdown
Contributor Author

VR-5d29bd61: Fixed in 8135293: skip-and-count removed from this PR; a malformed row now fails the read as it did before, so nothing is hidden. Showing partial lists is tracked in #353. A refresh that hits a malformed row now gets ApiError(200), which is not a permanent refusal, so the row is retried with backoff rather than left stale.


Generated by Claude Code

@vycari-review

vycari-review Bot commented Nov 23, 2026

Copy link
Copy Markdown

@greptileai review

Comment thread src/pepper_cli/api_client.py Resolved
_note_comments_from_dict called int() on resolved_count, so an object
or list value escaped as TypeError. A new _wire_opt helper returns the
default for a missing or null value and raises the malformed-response
ApiError for any other wrong type (a bool is never an int). It is used
for resolved_count and for the bare str() coercions in this PR's typed
parsers: a note comment's body, created_at and author name, the note
comments artifact_id, the room todos name and the blog publish/withdraw
card.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QNDehAurHo1CzCzisi6nYx
@vycari-review

vycari-review Bot commented Nov 23, 2026

Copy link
Copy Markdown

@greptileai review

@allenhutchison
allenhutchison added this pull request to the merge queue Nov 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 23, 2026
Keep main's stricter device-start validator (#346) and drop this branch's
now-redundant device-start test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QNDehAurHo1CzCzisi6nYx
@allenhutchison
allenhutchison added this pull request to the merge queue Nov 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 23, 2026
Take main's raw-dict blog methods, send their shape checks through
_wire_row so a malformed reply carries no body, keep list_apps on
_wire_list, and retarget the blog test at withdraw_blog_post.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QNDehAurHo1CzCzisi6nYx
@allenhutchison
allenhutchison added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit 8392b98 Nov 23, 2026
5 checks passed
@allenhutchison
allenhutchison deleted the claude/project-thread-r1mf6t-cli-310-parsers branch November 23, 2026 04:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Normalize malformed API response failures across typed parsers

2 participants