Skip to content

fix: resolve an enum route parameter from a qualified name - #155

Merged
gmpassos merged 2 commits into
masterfrom
fix/enum-route-parameter
Sep 2, 2026
Merged

fix: resolve an enum route parameter from a qualified name#155
gmpassos merged 2 commits into
masterfrom
fix/enum-route-parameter

Conversation

@gmpassos

@gmpassos gmpassos commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

A route parameter typed as an enum threw when the value arrived as a qualified
name (Currency.brl) — the form Enum.toString() produces, and the one
external callers tend to send:

[SEVERE] Error calling route `updateOrderStatusFromBroker` of module `external_integration`!
parameters: {..., paymentType: PaymentType.creditCard, chargedCurrency: Currency.BRL, ...}
[ERROR] type 'String' is not a subtype of type 'Currency?' of 'chargedCurrency'
#1  Function._apply
#3  MethodInvocation.invoke (package:reflection_factory)
#4  _APIRouteHandlerAPIMethodReflection.callImpl (package:bones_api/src/bones_api_module.dart:1788)

Cause

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. The bare name (brl), in
any case, already resolved.

Fixed upstream in reflection_factory: ^2.10.0, which accepts the qualified
form and requires the prefix to match the reflected enumName, so a String
from a different enum still resolves to null rather than matching by value
name.

Changes

  • deps: reflection_factory: ^2.9.0^2.10.0 (regenerated the test
    reflection files: builder version line only).
  • New test/bones_api_route_enum_parameter_test.dart, reproducing the
    production call — an external_integration module with an
    updateOrderStatusFromBroker route taking PaymentType? and Currency?.
    Five cases: qualified name (the failing one), bare name, case-insensitive
    name, JSON payload, and omitted (null) enum parameters.
  • Version 1.16.01.16.1, in pubspec.yaml, BonesAPI.VERSION and the
    CHANGELOG.

Test

The new test fails on 2.9.0 (qualified-name case only) and passes on 2.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

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

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.33%. Comparing base (b1fa4c4) to head (cdf2ec1).

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     
Flag Coverage Δ
unittests 68.33% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

`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
@gmpassos
gmpassos merged commit 7b6773c into master Sep 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant