FIX: get_node_repr crash on unhashable key when is_cached=False#219
Merged
Conversation
get_node_repr in modelx/core/execution/trace.py tested `key in obj.data` without checking obj.is_cached. When is_cached=False, keys may be unhashable (e.g. list args), so formatting a node repr from the formula error traceback raised TypeError: unhashable type, masking the real exception. Guard the membership test with `obj.is_cached`, matching the precedent in modelx/core/execution/executor.py:34. When is_cached=False, obj.data is empty anyway, so the check could never succeed. Add regression test test_formula_error_uncached_unhashable that triggers the crash via ErrorStack.tracemessage on an uncached cell with a list argument. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
get_node_reprinmodelx/core/execution/trace.py(line 109) testedkey in obj.datawithout first checkingobj.is_cached. Whenis_cached=False, formula keys may be unhashable (e.g. list arguments — the documented use case for disabling caching), so the membership test raisedTypeError: unhashable type: 'list', masking the real exception.ErrorStack.tracemessage(modelx/core/execution/executor.py:414) whenever an uncached cell raises an exception while called with an unhashable argument.obj.is_cached, matching the precedent atmodelx/core/execution/executor.py:34. Sinceobj.datais empty whenis_cached=False, short-circuiting is both safe and correct.Test plan
test_formula_error_uncached_unhashableinmodelx/tests/core/cells/test_error.py. Verified it reproduces the originalTypeErroragainst the unfixed code, and passes after the fix.pytest modelx/tests/core/cells/— 94 passed, 1 pre-existing skip, no regressions.🤖 Generated with Claude Code