fix: _AllowedSurfaceIDs.__call__ silently returning None on malformed surface info#5049
Open
fix: _AllowedSurfaceIDs.__call__ silently returning None on malformed surface info#5049
Conversation
2 tasks
Up to standards ✅🟢 Issues
|
…ndexError Agent-Logs-Url: https://github.com/ansys/pyfluent/sessions/068476b6-21c5-4c0a-a683-3096b157ad4f Co-authored-by: Gobot1234 <50501825+Gobot1234@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix silent failures in _AllowedSurfaceIDs.__call__ method
Fix _AllowedSurfaceIDs.__call__ silently returning None on malformed surface info
Apr 2, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves error reporting in the field data surface-ID lookup path by ensuring malformed surface metadata triggers a descriptive exception at the source, rather than returning None and failing later with an unrelated TypeError.
Changes:
- Updated
_AllowedSurfaceIDs.__call__to iterate per-surface and raise a descriptiveLookupErroron missingsurface_idor emptysurface_idlist. - Added unit tests covering both malformed-surface-info cases and verifying
_SurfaceIds.validatepropagates theLookupError.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/ansys/fluent/core/field_data_interfaces.py |
Replace silent exception swallow/implicit None return with explicit per-surface LookupErrors containing the surface name and failure mode. |
tests/test_field_data.py |
Add regression tests for missing surface_id key, empty surface_id list, and propagation through _SurfaceIds.validate. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
prmukherj
approved these changes
Apr 7, 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.
_AllowedSurfaceIDs.__call__silently swallowedKeyError/IndexErrorand returnedNone, causing a confusing downstreamTypeError: argument of type 'NoneType' is not iterablein_SurfaceIds.validate.Context
When a surface entry in
_get_surfaces_info()is missing thesurface_idkey or has an emptysurface_idlist, the method caught both exceptions and fell off the end, returningNone. Callers like_SurfaceIds.validatethen failed with aTypeErrorthat gave no indication of the actual root cause.Change Summary
_AllowedSurfaceIDs.__call__: replaced the silent catch-all with a per-surface loop that raises a descriptiveLookupErrornaming the offending surface and whether the failure was a missing key or empty index:KeyErrorpath, theIndexError(empty list) path, and propagation through_SurfaceIds.validate.Rationale
Raising a
LookupErrorwith the surface name pinpoints the bad data immediately, rather than silently producingNoneand letting an unrelatedTypeErrorsurface elsewhere.Impact
_AllowedSurfaceIDs.__call__and any callers that previously receivedNone(e.g.,_SurfaceIds.validate,_get_surface_ids) will now get a clearLookupErrorinstead of a silentNoneor a misleadingTypeError.