fix(data_service): resolve bare signal names + list-safe sort fallback - #278
Merged
Conversation
Sorting the grid by a signal (e.g. bce/sample) raised TypeError: unhashable type: 'list' and silently failed. Two causes: 1. Sort received the bare signal name (bce/sample) but the dataframe column is signals//bce/sample -> pandas KeyError. 2. The KeyError fallback did `by in df.columns` where by is a list, so pandas hashed the list -> TypeError. Fix: resolve bare signal names to their signals//<name> column before sorting, and make the fallback column-existence check list-safe. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes grid sorting failures when sorting by signal columns, particularly when the UI provides a bare signal name (e.g. bce/sample) but the dataframe uses prefixed signal columns (e.g. signals//bce/sample). It also hardens the error-recovery path to avoid TypeError: unhashable type: 'list' when by is a list.
Changes:
- Resolve bare signal names in
params["by"]tosignals//<name>when that prefixed column exists. - Make the KeyError/ambiguity fallback column-existence check list-safe (
all(...)) instead ofby in df.columns.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+3118
to
+3122
| # FIX: resolve bare signal names to their df column (signals//<name>) | ||
| _rb = params.get("by") | ||
| if _rb is not None: | ||
| _rbl = [_rb] if isinstance(_rb, str) else list(_rb) | ||
| _rbl = [(c if c in df.columns else ("signals//"+c if ("signals//"+c) in df.columns else c)) for c in _rbl] |
Comment on lines
+3118
to
+3122
| # FIX: resolve bare signal names to their df column (signals//<name>) | ||
| _rb = params.get("by") | ||
| if _rb is not None: | ||
| _rbl = [_rb] if isinstance(_rb, str) else list(_rb) | ||
| _rbl = [(c if c in df.columns else ("signals//"+c if ("signals//"+c) in df.columns else c)) for c in _rbl] |
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.
Sorting the grid by a signal (e.g. bce/sample) raised TypeError: unhashable type: 'list' and silently failed. Two causes:
by in df.columnswhere by is a list, so pandas hashed the list -> TypeError.Fix: resolve bare signal names to their signals// column before sorting, and make the fallback column-existence check list-safe.