Skip to content

Handle structured output review payloads#33

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

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

Conversation

@danielmartin
Copy link

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
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