Skip to content

fix(testing): match service for error size check and history redaction - #824

Open
nvasiu wants to merge 1 commit into
aws:mainfrom
nvasiu:fix/testing-error-size-and-history-redaction
Open

nvasiu wants to merge 1 commit into
aws:mainfrom
nvasiu:fix/testing-error-size-and-history-redaction

Conversation

@nvasiu

@nvasiu nvasiu commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Issue #, if available:

N/A

Description of changes:

Fix two places where the Python local runner behaves differently than the service.

validators/checkpoint.py

  • Before, for an update that carried an error, the runner measures that the error object itself is <= than 32KB.
  • After, for an update that carries an error, the runner serializes the whole update and checks that it is <= than 1MB. Which matches the service validation.
    • The error message says "Error object size must be less than or equal to 1048576 bytes." even though it is measuring the entire update. This matches the message that the service gives.

model.py

  • Before, when history was requested without execution data (include_execution_data is false) events would still include the error payload while reporting Truncated: true.
  • After, every error event includes the error payload when execution data is requested (include_execution_data is true).
    • ContextFailed, CallbackFailed and CallbackTimedOut now pass the include flag. Before, they never passed it so they would always report Truncated: true even when data was requested.

And updated tests to match new behaviour.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@nvasiu
nvasiu temporarily deployed to ai-pr-review-runtime October 23, 2026 23:14 — with GitHub Actions Inactive
@nvasiu
nvasiu force-pushed the fix/testing-error-size-and-history-redaction branch from b0c2502 to 9856a34 Compare October 23, 2026 23:34
Measure the whole update in UTF-8 bytes against 1,048,576 when it
carries an error, instead of only the error object against 32,768.

Include the error payload in history events only when execution data
is requested.
@nvasiu
nvasiu force-pushed the fix/testing-error-size-and-history-redaction branch from 9856a34 to a1cc27d Compare October 23, 2026 23:48

@yaythomas yaythomas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new boundary tests make the size rule clear. The history changes omit error payloads when callers exclude execution data. I found issues in Unicode handling, successful-result handling, type checking, and the wait-history test. I think these need changes before approval. The commit subject also exceeds the repository’s 50-character limit.

if len(payload) > MAX_ERROR_PAYLOAD_SIZE_BYTES:
msg: str = f"Error object size must be less than {MAX_ERROR_PAYLOAD_SIZE_BYTES} bytes."
payload = json.dumps(
update.to_dict(), separators=(",", ":"), ensure_ascii=False

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With ensure_ascii=False, an unpaired surrogate in an exception message remains in payload. payload_size_bytes() then raises UnicodeEncodeError because it uses strict UTF-8 encoding.

I reproduced this with ErrorObject.from_message("No such file: \udcff"). Can you make the byte-count helper handle this string without raising and add this case to checkpoint_test.py? Using errors="replace" is one option.

assert error is not None
assert error.truncated is (not include)
if include:
assert error.payload.message == "boom"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EventError.payload has type ErrorObject | None. Mypy rejects the direct .message access on this line. Can you assert error.payload is not None before checking its message?

_assert_error_redaction(getattr(event, event_details_attr).error, include)


@pytest.mark.parametrize("include", [True, False])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test passes a CANCEL update directly to Event.create_wait_event(). Executor.get_execution_history() does not pass that update when it builds a WaitCancelled event. So this test does not cover the behavior returned by get_execution_history().

Can you replace this with a test that exercises get_execution_history() and asserts the returned WaitCancelled event?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EventResult.from_durable_execution_invocation_output() returns durable_execution_invocation_output.result even when include=False. I ran a successful execution and requested its history with include_execution_data=False. The returned ExecutionSucceededDetails.Result still contained the result payload.

Can you apply the include check to this factory? Can you also add an end-to-end test through get_execution_history() that covers successful and failed executions with the flag enabled and disabled?

@yaythomas

Copy link
Copy Markdown
Contributor

The commit subject contains 70 characters. The repository allows at most 50. The commit-validation job therefore fails. Can you shorten the subject to 50 characters or fewer?

@yaythomas yaythomas mentioned this pull request Oct 25, 2026
3 tasks done

This branch was previously deployed

1 inactive (outdated) deployment
ai-pr-review-runtime — b0c25027 Deployed Oct 23, 2026 by nvasiu via notify / Generate notification summary #270
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