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

class Response<T> .toString() probably should contain whole class fields #2122

Closed
Wratheus opened this issue Feb 29, 2024 · 1 comment
Closed
Labels
i: wontfix This will not be worked on

Comments

@Wratheus
Copy link

Wratheus commented Feb 29, 2024

Package

dio

Version

5.4.1

Operating-System

iOS

Output of flutter doctor -v

[✓] Flutter (Channel stable, 3.19.1, on macOS 14.3.1 23D60 darwin-arm64, locale en-RU)
• Flutter version 3.19.1 on channel stable at /opt/homebrew/Caskroom/flutter/3.16.0/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision abb292a07e (9 days ago), 2024-02-20 14:35:05 -0800
• Engine revision 04817c99c9
• Dart version 3.3.0
• DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/aleksandrpavlenko/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15A507
• CocoaPods version 1.15.2

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] VS Code (version 1.84.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 14.3.1 23D60 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 122.0.6261.69

[✓] Network resources
• All expected network resources are available.

• No issues found!

Dart Version

3.3.0 (stable)

Steps to Reproduce

Response class .toString()

Expected Result

As topic says, I'm getting some inner flutter Http error in post dio request.
Response variable in my code and in dio post() call guaranteed as nonNull,

but my log func call (RESPONSE: response.toString), prints "RESPONSE: null", which can be obfusticated.
Later I encounted that current dio toString() looks like this and returns only Generic object

@override
  String toString() {
    if (data is Map) {
      // Log encoded maps for better readability.
      return json.encode(data);
    }
    return data.toString();
  }
      "RESPONSE: $response"
          .log(name: method, level: _getResponseLogLevel(response: response));
Response<dynamic> response = await App.dio
          .post('${AppConfig.domainApi}V${AppConfig.vApi}/$method',
              data: FormData.fromMap(_queryParameters(queryParameters)),
              cancelToken: options.cancelToken)
          .catchError(
        (e) async {
          return Response(
            requestOptions: RequestOptions(),
            statusCode: 400,
            statusMessage: e.toString(),
          );
        },

expected result

[log] 🧨[13:10:06]RESPONSE: Response{data: null, requestOptions: Instance of 'RequestOptions', statusCode: 400, statusMessage: DioException [unknown]: null
Error: HttpException: Connection closed before response was received, uri = <my_api_path>, headers: , isRedirect: false, redirects: [], extra: {}}

Actual Result

[log] 🧨[13:18:06][ERROR][cell/get] - RESPONSE: null

@Wratheus Wratheus added h: need triage This issue needs to be categorized s: bug Something isn't working labels Feb 29, 2024
@AlexV525
Copy link
Member

Response can have unexpected large size that affects the whole log thread and stuck the session. We have LogInterceptor that logs some types of response in a pretty format. And it should be easy to add your own interceptor to log responses with your own expectation.

@AlexV525 AlexV525 added i: wontfix This will not be worked on and removed h: need triage This issue needs to be categorized s: bug Something isn't working labels Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i: wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants