Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive call of send for Authenticator updated request is type erased #259

Closed
imatok opened this issue May 19, 2021 · 2 comments
Closed

Comments

@imatok
Copy link

imatok commented May 19, 2021

Hello,

when using Authenticator to refresh access token and update the original unauthorised failing request, I have an issue with my custom Response Converter cause response BodyType and InnerType are not propagated in that recursive send.

      if (updatedRequest != null) {
        res = await send(updatedRequest);
      }

Problem is, that recursive call succeeds and this _handleSuccessResponse<BodyType, InnerType> is executed without types:

    if (_responseIsSuccessful(response.statusCode)) {
      res = await _handleSuccessResponse<BodyType, InnerType>(
        res,
        responseConverter,
      );
    } else {
      res = await _handleErrorResponse<BodyType, InnerType>(res);
    }

that fails in my Response Converter that cannot resolve to correct BodyType/InnerType.
Also, after the recursive call is successfully done, returned response is not tested by this first line above: if (_responseIsSuccessful(response.statusCode)) but the old final one:

    final response = await http.Response.fromStream(streamRes);

so, the execution of original request proceeds with that else error path.

Quick fix would be to change line 317 to:

   res = await send<BodyType, InnerType>(updatedRequest);

and line 321 to:

    if (_responseIsSuccessful(res.statusCode)) {

but I haven't run any of your tests, except trying this out in my own code. :)
Additionally, when using this recursive call, same response gets processed twice, 1st time in recursive call and then when recursion returns replaced res value.

BR.

JEuler added a commit that referenced this issue May 30, 2021
@JEuler JEuler mentioned this issue May 30, 2021
@JEuler
Copy link
Collaborator

JEuler commented May 30, 2021

#263

JEuler added a commit that referenced this issue May 31, 2021
@JEuler JEuler mentioned this issue Jun 1, 2021
@JEuler
Copy link
Collaborator

JEuler commented Jun 1, 2021

Released fix in 4.0.1

@JEuler JEuler closed this as completed Jun 1, 2021
JEuler added a commit that referenced this issue Oct 8, 2022
JEuler added a commit that referenced this issue Oct 15, 2022
* Fix Header Option Casting (#260)

Co-authored-by: Ivan Terekhin <[email protected]>

* Fix for #259 (#263)

* 4.0.1 fixes (#264)

* analyzer dependency upgraded (#296)

* fix(generator): fix PartValueFile value not nullable if arg is (#288) (#293)

* Chopper generator release 4.0.2 (#297)

* fix: fix this.body cast of null value when response body is null (#291) (#292)

* Interpolation fixes (#275)

* encodeQueryComponent now encodeComponent (#278)

* Prevent double call on token refreshment (#276)

* Fixes for #309 #308 (#310)

* Remove new keyword from interceptors.md (#312)

* Analyzer upgrade (#320)

Co-authored-by: István Juhos <[email protected]>

* Add unnecessary_brace_in_string_interps to lint ignores (#317)

* Extend pragma to quiet the linter (#318)

Co-authored-by: Ivan Terekhin <[email protected]>

* Fix converter getting called twice if using an authenticator with a JsonConverter on the request (#324)

* migrate example to nullsafety (#331)

* Resolve problem in main_json_serializable example (#328)

* Add @FiledMap @PartMap @PartFileMap (#335)

Co-authored-by: Meysam Karimi <[email protected]>

* Upgrade of analyzer (#340)

* Fix nullable QueryMap fails to compile (#344)

* Change return type of decodeJson to FutureOr in order to be able to support compute() (#345)

* Migrate from pedantic to lints ^2.0.0 with lints/recommended.yaml (#349)

* Version bumped for release (#352)

* Revert analyzer to ^4.1.0 and silence linters for Element.enclosingElement (#354)

* [chopper_generator] Update analyzer to ^4.4.0 and code_builde to ^4.3.0 and migrate deprecated code (#358)

* Add Makefiles to streamline development (#357)

* Add Bug Report Github issue template (#359)

* [chopper_generator] Add types to the generated variables (#360)

* Provide an example using an Isolate Worker Pool with Squadron (#361)

* mapToQuery changes (#364)

* Version bumped / changelog update (#367)

* Request extends http.BaseRequest (#370)

* Exclude null query vars by default and add new @method annotation includeNullQueryVars (#372)

* 5.1.0 (dev) (#373)

Co-authored-by: Ivan Terekhin <[email protected]>

Co-authored-by: Youssef Raafat <[email protected]>
Co-authored-by: luis901101 <[email protected]>
Co-authored-by: melvspace <[email protected]>
Co-authored-by: Michal Šrůtek <[email protected]>
Co-authored-by: István Juhos <[email protected]>
Co-authored-by: Andre <[email protected]>
Co-authored-by: John Wimer <[email protected]>
Co-authored-by: Max Röhrl <[email protected]>
Co-authored-by: ipcjs <[email protected]>
Co-authored-by: ibadin <[email protected]>
Co-authored-by: Meysam Karimi <[email protected]>
Co-authored-by: Meysam Karimi <[email protected]>
Co-authored-by: Klemen Tusar <[email protected]>
Co-authored-by: Klemen Tusar <[email protected]>
Co-authored-by: Ivan Terekhin <[email protected]>
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

No branches or pull requests

2 participants