Skip to content

FIX: get_node_repr crash on unhashable key when is_cached=False#219

Merged
fumitoh merged 1 commit into
mainfrom
fix/get-node-repr-unhashable-key
May 4, 2026
Merged

FIX: get_node_repr crash on unhashable key when is_cached=False#219
fumitoh merged 1 commit into
mainfrom
fix/get-node-repr-unhashable-key

Conversation

@fumitoh
Copy link
Copy Markdown
Owner

@fumitoh fumitoh commented May 4, 2026

Summary

  • get_node_repr in modelx/core/execution/trace.py (line 109) tested key in obj.data without first checking obj.is_cached. When is_cached=False, formula keys may be unhashable (e.g. list arguments — the documented use case for disabling caching), so the membership test raised TypeError: unhashable type: 'list', masking the real exception.
  • The crash is reachable from ErrorStack.tracemessage (modelx/core/execution/executor.py:414) whenever an uncached cell raises an exception while called with an unhashable argument.
  • Fix: guard the membership test with obj.is_cached, matching the precedent at modelx/core/execution/executor.py:34. Since obj.data is empty when is_cached=False, short-circuiting is both safe and correct.

Test plan

  • Added test_formula_error_uncached_unhashable in modelx/tests/core/cells/test_error.py. Verified it reproduces the original TypeError against 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

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>
@fumitoh fumitoh merged commit b301674 into main May 4, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant