fix: BaseTask.get_id potentially returning None#5047
Open
Conversation
2 tasks
Agent-Logs-Url: https://github.com/ansys/pyfluent/sessions/7757a4b3-49ee-4d7e-9df4-6f8b2f8d9ac6 Co-authored-by: Gobot1234 <50501825+Gobot1234@users.noreply.github.com>
Agent-Logs-Url: https://github.com/ansys/pyfluent/sessions/7757a4b3-49ee-4d7e-9df4-6f8b2f8d9ac6 Co-authored-by: Gobot1234 <50501825+Gobot1234@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix BaseTask.get_id potentially returning None
Fix BaseTask.get_id returning None when task ID not found
Apr 2, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prevents BaseTask.get_id() from implicitly returning None when the workflow state cannot be matched to the current task, avoiding downstream TypeErrors and making the failure explicit.
Changes:
- Add a terminal
RuntimeErrorinBaseTask.get_id()when no task ID can be resolved from the workflow state.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Up to standards ✅🟢 Issues
|
Collaborator
|
I don't think this really needs a test as it's covered by type checking |
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.
BaseTask.get_id()silently returnedNonewhen no matching task was found in the workflow state, causing an obscureTypeErrordownstream inget_idx()when attempting to subscript theNoneresult.Context
get_id()iterated over workflow state without a fallback, returningNoneon a miss. Callers likeget_idx()assumed astrreturn, producing:Change Summary
raise RuntimeError(...)at the end ofBaseTask.get_id()to surface the failure at the source with a clear, actionable message including the task name:Rationale
Failing fast with a descriptive error is preferable to propagating
Noneand producing a confusingTypeErrorseveral call frames away. Including the task name in the message aids debugging without requiring a stack trace inspection.Impact
Any code path that reaches
get_id()with a task not present in the workflow state will now raiseRuntimeErrorimmediately instead of silently returningNone. The return type contract (str) is now enforced at runtime.