Skip to content

Fix stale presenter after expected operation errors#2589

Open
zainnadeem786 wants to merge 1 commit into
gchq:masterfrom
zainnadeem786:fix/render-pdf-error-presentation
Open

Fix stale presenter after expected operation errors#2589
zainnadeem786 wants to merge 1 commit into
gchq:masterfrom
zainnadeem786:fix/render-pdf-error-presentation

Conversation

@zainnadeem786

@zainnadeem786 zainnadeem786 commented Jun 22, 2026

Copy link
Copy Markdown

Summary

Fix an issue where an expected OperationError or DishError could be rendered using a stale presenter from a previously successful operation.

This was reproducible with the following chain:

Render PDF
↓
Generate QR Code (OperationError)

where the expected plain error message was incorrectly returned as an HTML PDF iframe.

Root Cause

Recipe.execute() resets lastRunOp at the beginning of execution and updates it after each successful operation.

When an operation throws an expected OperationError or DishError, the error message is written to the dish as a "string" and execution returns early, but lastRunOp is left unchanged.

Chef.bake() subsequently calls Recipe.present(), which uses the stale presenter from the previous successful operation. As a result, the error string can be wrapped using an unrelated presenter instead of being returned as plain text.

Fix

Clear the presentation state on the expected error paths by resetting lastRunOp before returning.

This keeps the error dish unpresented and allows the plain error message to be returned as intended.

The fix is generic and is applied to both:

  • OperationError
  • DishError

without introducing any special handling for individual operations.

Regression Tests

Added focused regression coverage for the reported scenario:

  • Render PDF followed by Generate QR Code returns a plain QR error message.
  • The resulting output does not contain a PDF <iframe>.

Validation

Executed the relevant test suites:

Node API tests:
PASSING 250/250

Operation tests:
PASSING 2051/2051

Impact

@CLAassistant

CLAassistant commented Jun 22, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

bug(Render PDF, Chained): chaining render pdf with generate qr code will result on html output

2 participants