Fix groupTuple operator GString vs String key handling#6400
Fix groupTuple operator GString vs String key handling#6400pditommaso merged 1 commit intomasterfrom
Conversation
The groupTuple operator was not properly grouping items when the same logical key was represented as both GString and String objects. This occurred when channel values contained interpolated strings (GString) that were later mixed with regular String literals having the same content. The root cause was that GString and String objects with identical content have different hash codes and equality behavior, causing them to be treated as separate grouping keys. This commit adds key normalization in the groupTuple operator that converts GString objects to String while preserving all other data types unchanged. Changes: - Add normalizeKey() method to convert GString elements to String - Modify collect() method to normalize keys before grouping - Add comprehensive unit tests covering GString/String scenarios - Preserve existing behavior for all non-GString key types Fixes #6399 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
✅ Deploy Preview for nextflow-docs-staging canceled.
|
|
@claude review |
|
Claude finished @pditommaso's task —— View job Code ReviewI've reviewed the PR that fixes GString vs String key handling in the groupTuple operator. Overall, this is a solid fix for a real problem with clean implementation. Tasks
Review Summary✅ Strengths:
📋 Code Quality:
🧪 Test Quality:
Detailed AnalysisImplementation (GroupTupleOp.groovy:94, 265-272)The fix is minimal and surgical: final key = normalizeKey(tuple[indices]) // Line 94The
Edge Cases Considered ✅
Potential Improvements (Minor)
Backward Compatibility ✅
ConclusionThis is a well-implemented fix that addresses the root cause of the GString/String grouping issue. The solution is minimal, focused, and well-tested. The approach of normalizing keys before grouping is the correct strategy, and the implementation handles edge cases appropriately. Recommendation: Approve - This fix resolves the issue without introducing risks or breaking changes. |
|
This is not needed because it is already addressed in the strict syntax at the compiler level. If you tried to fix it at the runtime level like this, you would have to add extra logic to every possible location where a string might be compared to a gstring, and even then you probably wouldn't catch every case. |
Summary
Fixes the
groupTupleoperator to consistently handle GString vs String keys that represent the same logical value.Problem
The
groupTupleoperator was not properly grouping items when the same logical key was represented as both GString and String objects. This occurred when:"${variable}"- GStringImpl)"same_value"- String)Root Cause
GString and String objects with identical content have different:
==returns false between GString and String)This caused them to create separate entries in the internal grouping map.
Solution
Added key normalization in the
groupTupleoperator:Changes
GroupTupleOp.groovy:
normalizeKey()method to convert GString elements to Stringcollect()method to normalize keys before groupingGroupTupleOpTest.groovy:
Test Plan
Related Issues
Fixes #6399
🤖 Generated with Claude Code