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

DioError [DioErrorType.response] v5.0 #1676

Closed
a1ssat opened this issue Feb 20, 2023 · 8 comments
Closed

DioError [DioErrorType.response] v5.0 #1676

a1ssat opened this issue Feb 20, 2023 · 8 comments

Comments

@a1ssat
Copy link

a1ssat commented Feb 20, 2023

Package

dio

Version

5.0.0

Output of flutter doctor -v

[✓] Flutter (Channel stable, 3.7.3, on linux 6.1.12-zen1-1-zen, locale en_US.UTF-8)
    • Flutter version 3.7.3 on channel stable at /opt/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 9944297138 (11 days ago), 2023-02-08 15:46:04 -0800
    • Engine revision 248290d6d5
    • Dart version 2.19.2
    • DevTools version 2.20.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /opt/android-sdk
    • Platform android-33, build-tools 33.0.1
    • ANDROID_HOME = /opt/android-sdk
    • Java binary at: /usr/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.18+10)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /usr/bin/chromium

[✓] Linux toolchain - develop for Linux desktop
    • clang version 15.0.7
    • cmake version 3.25.2
    • ninja version 1.11.1
    • pkg-config version 1.8.0


[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • linux 6.1.12-zen1-1-zen
    • Chrome (web)    • chrome • web-javascript • Chromium 110.0.5481.100 Arch Linux

[✓] HTTP Host Availability
    • All required HTTP hosts are available

Dart Version

2.19.2

Steps to Reproduce

requests working fine on 4.0.6 but when I upgrade to 5, i got Status: 400 Bad Request #1171

flutter: ║  https://api.********com/graphql
flutter: ╚══════════════════════════════════════════════════════════════════════════════════════════╝
flutter: ╔ Headers
flutter: ╟ content-type: application/json
flutter: ╟ contentType: application/json
flutter: ╟ responseType: ResponseType.json
flutter: ╟ accept: */*
flutter: ╟ followRedirects: true
flutter: ╟ connectTimeout: null
flutter: ╟ receiveTimeout: null
flutter: ╚══════════════════════════════════════════════════════════════════════════════════════════╝

Expected Result

flutter: ║  https://api.********com/graphql
flutter: ╚══════════════════════════════════════════════════════════════════════════════════════════╝
flutter: ╔ Body
flutter: ║
flutter: ║    {
flutter: ║         data: {
flutter: ║             __typename: "Mutation",
flutter: ║             login: {
flutter: ║                 __typename: "Login******",
flutter: ║                 "eyJhbGciOi*********"
flutter: ║                 "eyJhbGciOiJI*************"
flutter: ║            }
flutter: ║        }
flutter: ║    }
flutter: ║
flutter: ╚══════════════════════════════════════════════════════════════════════════════════════════╝

Actual Result

flutter: ║  https://api.********com/graphql
flutter: ╚══════════════════════════════════════════════════════════════════════════════════════════╝
flutter: ╔ DioErrorType.badResponse
flutter: ║ POST body missing, invalid Content-Type, or JSON object has no keys.
flutter: ╚══════════════════════════════════════════════════════════════════════════════════════════╝```
@a1ssat a1ssat added h: need triage This issue needs to be categorized s: bug Something isn't working labels Feb 20, 2023
@AlexV525
Copy link
Member

This will be resolved by #1671 once the new version is released.

@aissat
Copy link

aissat commented Feb 27, 2023

@AlexV525 this issue not fixed

  dio: ^5.0.1
  gql_dio_link: ^0.3.0
  pretty_dio_logger: ^1.3.1
[log] ║  https://a*********.com/graphql
[log] ╚══════════════════════════════════════════════════════════════════════════════════════════╝
[log] ╔ Headers
[log] ╟ Accept: */*
[log] ╟ content-type: application/json
[log] ╟ contentType: application/json
[log] ╟ responseType: ResponseType.json
[log] ╟ followRedirects: true
[log] ╟ connectTimeout: null
[log] ╟ receiveTimeout: null
[log] ╚══════════════════════════════════════════════════════════════════════════════════════════╝
[log] DioInterceptor=>onRequest=>path: /graphql
[log] interceptor: refresh expired
[log] ╔╣ DioError ║ Status: 400 Bad Request
[log] ║   https://a*********.com/graphql
[log] ╚══════════════════════════════════════════════════════════════════════════════════════════╝
[log] ╔ DioErrorType.badResponse
[log] ║ POST body missing, invalid Content-Type, or JSON object has no keys.
[log] ╚══════════════════════════════════════════════════════════════════════════════════════════╝

@AlexV525
Copy link
Member

#1648 (comment)

@aissat
Copy link

aissat commented Feb 27, 2023

#1648 (comment)

same thing 👎

@AlexV525
Copy link
Member

Please provide your minimal reproducible example about the empty body. As a reference, setting up a test like

test('default content-type', () async {
would be helpful to find the root cause.

@AlexV525 AlexV525 reopened this Feb 27, 2023
@aissat
Copy link

aissat commented Feb 27, 2023

@AlexV525 this code working well with version 4.0.6

....
client = Dio(
      BaseOptions(
        baseUrl: 'https://a*********.com/',
        headers: {
          HttpHeaders.userAgentHeader: 'app',
        },
      ),
    );
...
....
client.interceptors.add(AuthInterceptors());
    var dioLink = Link.from([DioLink('/graphql', client: client)]);
    _graphQLClient = GraphQLClient(
      cache: GraphQLCache(store: InMemoryStore()),
      link: dioLink,
    );
...
....
    var queryOpt = QueryOptions(
        document: parseString(query),
        variables: vars,
        fetchPolicy: FetchPolicy.networkOnly);
    var res = await _graphQLClient.query(queryOpt);

    if (res.hasException) throw Exception(res.exception);
...

after version 5.0.0 I got this issues, i tried to add contentType but no thing change

@AlexV525 AlexV525 added the h: need more info Further information is requested label Feb 28, 2023
@AlexV525
Copy link
Member

AlexV525 commented Feb 28, 2023

Can you simplify your code with some raw requests? More specifically, we don't know what happened with QueryOptions, client.query, Link.from. It would be better of you can reproduce the exception using a minimal example without any business logic.

@AlexV525
Copy link
Member

AlexV525 commented Mar 9, 2023

Unfortunately we cannot proceed without additional info for requests. Please consider providing a minimal reproducible example and submit a new issue so we can identify where and what is the root cause. Thanks.

@AlexV525 AlexV525 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 9, 2023
@AlexV525 AlexV525 added i: cannot reproduce and removed h: need more info Further information is requested h: need triage This issue needs to be categorized s: bug Something isn't working labels Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants