Skip to content

Handle structured output review payloads - #33

Merged
danielmartin merged 1 commit into
PSPDFKit-labs:mainfrom
danielmartin:dmartin/structured-output-fallback
Mar 6, 2026
Merged

Handle structured output review payloads#33
danielmartin merged 1 commit into
PSPDFKit-labs:mainfrom
danielmartin:dmartin/structured-output-fallback

Conversation

@danielmartin

Copy link
Copy Markdown

This fixes a failure mode in the review parser.

Right now we only parse Claude's serialized result field. In recent runs, Claude sometimes returned the valid review payload in structured_output while result was empty, which made the action drop a good response and degrade into an empty review.

This patch checks structured_output first, falls back to result for compatibility, and fails the run if neither contains a valid review payload. That follows the same direction as Anthropic's claude-code-action, which treats structured_output as the schema-backed output path: https://github.com/anthropics/claude-code-action/blob/main/base-action/src/run-claude-sdk.ts#L208-L228

Tests are updated to cover the structured_output path and the failure case.

Claude can return review data in `structured_output` even when the legacy `result` field is empty. The current parser only looks at `result`, so a valid review payload can be lost and the action can degrade into an empty review.

This change checks `structured_output` first, falls back to parsing `result` for compatibility, and fails the review if neither contains a valid payload. The tests now cover the `structured_output` path and the failure case so the action does not silently approve malformed responses.
@danielmartin danielmartin self-assigned this Mar 6, 2026
@danielmartin
danielmartin marked this pull request as ready for review March 6, 2026 15:58
@danielmartin
danielmartin requested a review from HungKNguyen March 6, 2026 15:58
@danielmartin
danielmartin merged commit 93563fc into PSPDFKit-labs:main Mar 6, 2026
2 of 3 checks passed
@danielmartin
danielmartin deleted the dmartin/structured-output-fallback branch March 6, 2026 19:02
amit-nayar added a commit that referenced this pull request Jul 16, 2026
Reviewers currently have to flip a PR out of draft to get a review, then
back into draft to keep working - `skip-draft-prs` applies
unconditionally to every trigger, including an explicit `@bot` mention
or the `review` comment command.

This builds on Daniel Martin's unmerged fork commits
(`danielmartin/nutrient-code-review`) which add the plain `review`
comment command and split `ready_for_review` into its own trigger, then
adds the missing piece: the draft-PR skip now exempts `mention` and
`slash_command` triggers, since those are an explicit per-PR request
from a human rather than automatic noise. Automatic triggers (`open`,
`commit`, `ready_for_review`) are unaffected and still fully respect
`skip-draft-prs`.

One commit from Daniel's fork ("Backport parser and ready-state fixes")
was dropped - it re-applied an older, less strict version of
review-payload parsing that's already superseded by what's on `main` (PR
#33), so it only produced merge conflicts with no behavioral gain.

Consumer: PSPDFKit/PSPDFKit#55849 pins to this branch and is blocked on
this merging.

---------

Co-authored-by: Daniel Martín <mardani29@yahoo.es>
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.

2 participants