fix: safely parse task state and execution info in get_task_status#145
Merged
cdc-as81 merged 1 commit intorr-142-task-statusfrom Mar 26, 2026
Merged
fix: safely parse task state and execution info in get_task_status#145cdc-as81 merged 1 commit intorr-142-task-statusfrom
cdc-as81 merged 1 commit intorr-142-task-statusfrom
Conversation
Use getattr to handle missing execution_info for active tasks Safely fallback to string parsing when task.state is not an Enum Add tests for string-based pre-execution task states
ryanraaschCDC
approved these changes
Mar 26, 2026
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.
Fix task status parsing for pre-execution tasks
Motivation
This PR fixes a bug where
get_task_status()crashes when encountering Azure Batch tasks that have not yet started executing or that return string-based states rather than enums.Changes Made
getattr()to safely extract the state value, falling back to string conversion to handle cases where the Azure SDK returns a plain string rather than aTaskStateenum.getattr()to conditionally retrievetask.execution_info.exit_code, defaulting toNone. This preventsAttributeErrorcrashes for tasks in pre-run states (likeactive) that lack execution metadata entirely.activestring state and unpopulated (None)execution_infototest_get_task_status_all_tasks()to guarantee these edge cases are exercised.