fix: support enum fields in query and path parameters#152
Conversation
… example Address all review feedback from SebastienMelki#151 and PR SebastienMelki#152: - Add forward-compat comment explaining why unknown enum numbers are accepted (proto3/protojson alignment) - Improve error message to include enum type name: invalid value "FOO" for enum Timeframe - Enable enum as path parameter type in isPathParamCompatible() - Filter empty query param strings (?param=) as unset - Fix TS server generator: cast enum path params (as Region) and repeated enum query params (as Region[]) - Add 11 runtime test cases covering valid name, numeric, UNSPECIFIED, unknown name/number, wrong case, empty string, repeated enum, and path param variants - Add examples/enum-params/ with Timeframe + AssetClass enums demonstrating query and path parameter usage end-to-end - Document supported query/path parameter types in http-generation.md with enum section and examples - Regenerate all golden files across all 5 generators Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Latest push addresses the review feedback: Changes:
Tests (11 runtime cases in
Example: Docs: Added "Supported Query & Path Parameter Types" section to Co-authored-by: Claude Code |
16cce80 to
356c332
Compare
… example Address all review feedback from SebastienMelki#151 and PR SebastienMelki#152: - Add forward-compat comment explaining why unknown enum numbers are accepted (proto3/protojson alignment) - Improve error message to include enum type name: invalid value "FOO" for enum Timeframe - Enable enum as path parameter type in isPathParamCompatible() - Filter empty query param strings (?param=) as unset - Fix TS server generator: cast enum path params (as Region) and repeated enum query params (as Region[]) - Add 11 runtime test cases covering valid name, numeric, UNSPECIFIED, unknown name/number, wrong case, empty string, repeated enum, and path param variants - Add examples/enum-params/ with Timeframe + AssetClass enums demonstrating query and path parameter usage end-to-end - Document supported query/path parameter types in http-generation.md with enum section and examples - Regenerate all golden files across all 5 generators Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Test results after rebasing on main: Passing (6/7 packages):
Failing (1/7 packages):
All enum-specific tests pass, including the 11 runtime test cases in Co-authored-by: Claude Code |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #152 +/- ##
========================================
- Coverage 4.97% 4.92% -0.06%
========================================
Files 35 35
Lines 4443 4490 +47
========================================
Hits 221 221
- Misses 4218 4265 +47
Partials 4 4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi @shavaizknz thanks for the fix! Can you please review the linting issue happening on the PR? Thank you |
The convertStringToFieldValue function lacked a case for protoreflect.EnumKind, causing enum query/path parameters to fail with "unsupported field type: enum". Add enum support that accepts both numeric values (e.g. 3) and proto enum names (e.g. TIMEFRAME_ALL) by looking up the value in the field's enum descriptor. The function signature is changed from accepting protoreflect.Kind to protoreflect.FieldDescriptor so the enum descriptor is available for name-based lookup. Fixes SebastienMelki#151 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… example Address all review feedback from SebastienMelki#151 and PR SebastienMelki#152: - Add forward-compat comment explaining why unknown enum numbers are accepted (proto3/protojson alignment) - Improve error message to include enum type name: invalid value "FOO" for enum Timeframe - Enable enum as path parameter type in isPathParamCompatible() - Filter empty query param strings (?param=) as unset - Fix TS server generator: cast enum path params (as Region) and repeated enum query params (as Region[]) - Add 11 runtime test cases covering valid name, numeric, UNSPECIFIED, unknown name/number, wrong case, empty string, repeated enum, and path param variants - Add examples/enum-params/ with Timeframe + AssetClass enums demonstrating query and path parameter usage end-to-end - Document supported query/path parameter types in http-generation.md with enum section and examples - Regenerate all golden files across all 5 generators Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
356c332 to
0c1f408
Compare
- goimports: reformat enum_query_test.go and tsservergen/generator.go - golines: wrap long lines in httpgen/generator.go and tsservergen/generator.go - govet shadow: rename inner err variables (mkErr, writeErr) to avoid shadowing the outer err in TestEnumQueryAndPathParams Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Linting issues resolved in the latest push. Reproduced locally with
All 9 actual CI checks now pass: Build Binaries, Coverage Analysis, Coverage Status Check, Integration Tests, Lint & Code Quality, Test (Go 1.26 macos + ubuntu), codecov/patch, codecov/project. The only failure is "PR Status Summary", but checking the job details shows it fails with Co-authored-by: Claude Code |
Summary
protoreflect.EnumKindcase toconvertStringToFieldValueso enum fields work as query/path parameters3) and proto enum name strings (e.g.TIMEFRAME_ALL) via the field's enum descriptor(string, protoreflect.Kind)to(string, protoreflect.FieldDescriptor)to enable enum name lookupFixes #151
Test plan
UPDATE_GOLDEN=1 go testto regenerate)internal/...tests pass?timeframe=TIMEFRAME_ALL)?timeframe=3)🤖 Generated with Claude Code