Fix TypeError in truncate_serialized_error when message is None#33667
Open
Krishnachaitanyakc wants to merge 1 commit intodagster-io:masterfrom
Open
Fix TypeError in truncate_serialized_error when message is None#33667Krishnachaitanyakc wants to merge 1 commit intodagster-io:masterfrom
Krishnachaitanyakc wants to merge 1 commit intodagster-io:masterfrom
Conversation
When deserializing older event log entries, the `message` field of `SerializableErrorInfo` can be `None`. The `truncate_serialized_error` function called `len(error_info.message)` without guarding against `None`, causing a `TypeError: object of type 'NoneType' has no len()` when viewing failed runs in the UI (via the `RunStepStatsQuery` GraphQL query). Fix by falling back to an empty string before computing the length, matching the defensive pattern already used for `cls_name` on line 271. Adds a regression test for the None message case. Fixes dagster-io#33662
Contributor
Greptile SummaryThis PR fixes a Key changes:
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| python_modules/dagster/dagster/_utils/error.py | Adds a None guard for error_info.message before calling len(), fixing a TypeError crash when deserializing older event log entries with a None message field. |
| python_modules/dagster/dagster_tests/utils_tests/test_errors.py | Adds test_truncate_serialized_error_none_message regression test that verifies truncate_serialized_error no longer raises TypeError when message=None, and confirms the None value is preserved in the result. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[truncate_serialized_error called] --> B{error_info.message is None?}
B -- Yes --> C["msg = '' (empty string)"]
B -- No --> D["msg = error_info.message"]
C --> E["msg_len = len(msg) → 0"]
D --> F["msg_len = len(msg)"]
E --> G{"msg_len > field_size_limit?"}
F --> G
G -- No --> H[message unchanged / None preserved]
G -- Yes --> I["error_info._replace(message=msg[:limit] + ' (TRUNCATED)')"]
Reviews (1): Last reviewed commit: "Fix TypeError in truncate_serialized_err..." | Re-trigger Greptile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #33662
Bug:
truncate_serialized_errorcallslen(error_info.message)without guarding againstNone. When deserializing older event log entries, themessagefield ofSerializableErrorInfocan beNone(the@recorddecorator haschecked=False, so runtime type enforcement is disabled). This causes aTypeError: object of type 'NoneType' has no len()crash when viewing failed runs in the Dagster UI via theRunStepStatsQueryGraphQL query.Fix: Fall back to an empty string (
error_info.message or "") before computing the length and slicing, consistent with the defensive pattern already used forcls_nameon the same function (line 271:if error_info.cls_name and len(...)).Test: Added a regression test
test_truncate_serialized_error_none_messagethat constructs aSerializableErrorInfowithmessage=Noneand verifiestruncate_serialized_errorhandles it without raising.Test plan
test_truncate_serialized_error_none_messageregression testtest_truncate_serialized_errorcontinues to pass