fix: correct TypeTag error message and harden vector parsing#248
fix: correct TypeTag error message and harden vector parsing#248
Conversation
… in TypeTagFromString Fix "known TypeTag" -> "unknown TypeTag" error message and use precise prefix/suffix matching for vector type parsing to avoid matching non-vector types that happen to start with "vector". Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughUpdated vector type parsing to require exact Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
api/exposed_test.go (1)
92-119: Add a direct regression case for non-vector<...>prefixes.Given the original bug, it’s worth explicitly asserting that inputs like
vectorFooare not treated as vectors.✅ Suggested test extension
func TestTypeTagFromString_NestedVector(t *testing.T) { @@ inner3 := inner2.Value.(*types.TypeTag__Vector) require.IsType(t, &types.TypeTag__U8{}, inner3.Value) + + // regression: should not match arbitrary "vector" prefix + _, err = TypeTagFromString("vectorFoo") + require.Error(t, err) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@api/exposed_test.go` around lines 92 - 119, Extend TestTypeTagFromString_NestedVector to add a regression assertion that inputs not using the proper "vector<...>" syntax (e.g. "vectorFoo") are not parsed as a vector: call TypeTagFromString("vectorFoo") inside TestTypeTagFromString_NestedVector and assert it returns an error (require.Error) or at minimum that the returned tag is not a *types.TypeTag__Vector (require.NotIsType), so the parser doesn't treat "vectorFoo" as a vector type.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@api/exposed_test.go`:
- Around line 92-119: Extend TestTypeTagFromString_NestedVector to add a
regression assertion that inputs not using the proper "vector<...>" syntax (e.g.
"vectorFoo") are not parsed as a vector: call TypeTagFromString("vectorFoo")
inside TestTypeTagFromString_NestedVector and assert it returns an error
(require.Error) or at minimum that the returned tag is not a
*types.TypeTag__Vector (require.NotIsType), so the parser doesn't treat
"vectorFoo" as a vector type.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 868f69b0-f3f5-4ced-b32d-fed68cc3b1e0
📒 Files selected for processing (2)
api/exposed.goapi/exposed_test.go
Per CodeRabbit review, ensure that strings starting with "vector" but not matching "vector<...>" syntax are not parsed as vector types. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
"known TypeTag"→"unknown TypeTag"inStringifyTypeTagerror fallbackTypeTagFromStringvector parsing to correctly handle nested types and reject non-vector prefixesBug details
Bug 1:
StringifyTypeTagreturnederrors.New("known TypeTag")for unrecognized variants — clearly should be "unknown".Bug 2:
TypeTagFromStringusedstrings.HasPrefix(str, "vector")which would match any string starting with "vector" (e.g., a hypothetical structvectorFoo). Changed to require bothvector<prefix and>suffix, then extract inner type viastr[7:len(str)-1].This correctly handles nested vectors:
vector<u8>→ inner:u8vector<vector<u8>>→ inner:vector<u8>→ recursion worksTest plan
TestStringifyTypeTag_UnknownError— verifies corrected error messageTestTypeTagFromString_NestedVector— tests depth 1, 2, and 3 nested vectors🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests