fix: resolve an enum route parameter from a qualified name - #155
Merged
Conversation
A route parameter typed as an `enum` threw when the value arrived as
`Currency.brl` — the form `Enum.toString()` produces, and the one external
callers tend to send:
type 'String' is not a subtype of type 'Currency?' of 'chargedCurrency'
`EnumReflection.from` only read a bare value name, so the qualified form
parsed to `null`, `APIRouteBuilder.resolveValueByType` fell back to the
value it was given, and the raw `String` reached `Function.apply`.
Fixed upstream in `reflection_factory: ^2.10.0`. Adds
`bones_api_route_enum_parameter_test.dart`, covering the qualified name
alongside the bare name, a case-insensitive name, a JSON payload and a
null `enum` parameter.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RVuPYBSbnLEWVqPXTcmZU2
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #155 +/- ##
==========================================
+ Coverage 68.31% 68.33% +0.01%
==========================================
Files 66 66
Lines 22322 22322
==========================================
+ Hits 15250 15254 +4
+ Misses 7072 7068 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
`dependency_validator` 5.0.6 fails to parse a `final` modifier on a formal
parameter, and the CI `build` job runs it:
Error parsing: ./lib/src/bones_api_logging.dart
Content produced diagnostics when parsed:
extraneous_modifier: Can't have modifier 'final' here. - 513:36
The modifier only barred reassignment inside the body, so dropping it from
the four parameters that carried it is a no-op.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RVuPYBSbnLEWVqPXTcmZU2
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.
A route parameter typed as an
enumthrew when the value arrived as a qualifiedname (
Currency.brl) — the formEnum.toString()produces, and the oneexternal callers tend to send:
Cause
EnumReflection.fromonly read a bare value name, so the qualified form parsedto
null,APIRouteBuilder.resolveValueByTypefell back to the value it wasgiven, and the raw
StringreachedFunction.apply. The bare name (brl), inany case, already resolved.
Fixed upstream in
reflection_factory: ^2.10.0, which accepts the qualifiedform and requires the prefix to match the reflected
enumName, so aStringfrom a different enum still resolves to
nullrather than matching by valuename.
Changes
deps:reflection_factory: ^2.9.0→^2.10.0(regenerated the testreflection files: builder version line only).
test/bones_api_route_enum_parameter_test.dart, reproducing theproduction call — an
external_integrationmodule with anupdateOrderStatusFromBrokerroute takingPaymentType?andCurrency?.Five cases: qualified name (the failing one), bare name, case-insensitive
name, JSON payload, and omitted (null)
enumparameters.1.16.0→1.16.1, inpubspec.yaml,BonesAPI.VERSIONand theCHANGELOG.Test
The new test fails on
2.9.0(qualified-name case only) and passes on2.10.0.The full local suite was not re-run for this PR — CI covers it.
🤖 Generated with Claude Code
https://claude.ai/code/session_01RVuPYBSbnLEWVqPXTcmZU2