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

request.uri have a different query parameter order than response.realUri and response.requestOptions.uri #2123

Closed
edeuss opened this issue Mar 3, 2024 · 7 comments

Comments

@edeuss
Copy link

edeuss commented Mar 3, 2024

Package

dio

Version

5.4.1

Operating-System

Android, iOS, Web

Output of flutter doctor -v

[✓] Flutter (Channel stable, 3.19.2, on macOS 14.2.1 23C71 darwin-arm64, locale en-US)
    • Flutter version 3.19.2 on channel stable at /Users/deuss/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7482962148 (5 days ago), 2024-02-27 16:51:22 -0500
    • 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/deuss/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.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C500b
    • 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.86.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.84.

Dart Version

No response

Steps to Reproduce

  1. Do a request to an url with multiple query parameters
  2. Log the request uri in the console (request.uri.toString())
  3. For the response, check the response.realUri.toString() and response.requestOptions.uri.toString() and see that they are not the same.

Expected Result

The response.realUri and response.requestOptions.uri have the same query parameter order as the request uri.

Actual Result

The response.realUri and response.requestOptions.uri have a different query parameter order than the request uri.

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

AlexV525 commented Mar 5, 2024

The test passes.

image
test('Query parameters equality', () async {
  final dio = Dio()
    ..httpClientAdapter = EchoAdapter()
    ..options.baseUrl = EchoAdapter.mockBase;
  const queryParameters = <String, String>{'a': '1', 'b': '2'};
  final response = await dio.get(
    '/test',
    queryParameters: queryParameters,
  );
  expect(
    response.realUri.queryParameters.toString(),
    equals(response.requestOptions.queryParameters.toString()),
  );
});

@AlexV525 AlexV525 added h: need more info Further information is requested i: cannot reproduce and removed h: need triage This issue needs to be categorized s: bug Something isn't working labels Mar 5, 2024
@edeuss edeuss changed the title response.realUri and response.requestOptions.uri have a different query parameter order request.uri have a different query parameter order than response.realUri and response.requestOptions.uri Mar 5, 2024
@edeuss
Copy link
Author

edeuss commented Mar 5, 2024

@AlexV525 I updated the title since it was incorrect, apologies.

Here is what's happening for us:

Uri we input: /tracks?range=months&orderBy=TIME
Response output: /tracks?orderBy=TIME&range=months

@AlexV525
Copy link
Member

AlexV525 commented Mar 5, 2024

image
test('Query parameters equality', () async {
  final dio = Dio()..httpClientAdapter = EchoAdapter();
  final uri = Uri.base.resolve(
    '${EchoAdapter.mockBase}/test?range=months&orderBy=TIME',
  );
  final response = await dio.getUri(uri);
  expect(
    response.realUri.queryParameters.toString(),
    equals(response.requestOptions.uri.queryParameters.toString()),
  );
});

@edeuss
Copy link
Author

edeuss commented Mar 5, 2024

@AlexV525 You are testing the uri's in the response object. Those are both the same, It's the uri in dio.getUri(uri); and the response object uri's that have the different query parameter order.

@AlexV525
Copy link
Member

AlexV525 commented Mar 5, 2024

image
test('Query parameters equality', () async {
  final dio = Dio()..httpClientAdapter = EchoAdapter();
  final uri = Uri.base.resolve(
    '${EchoAdapter.mockBase}/test?range=months&orderBy=TIME',
  );
  final response = await dio.getUri(uri);
  expect(
    response.realUri.queryParameters.toString(),
    equals(uri.queryParameters.toString()),
  );
});

@kuhnroyal
Copy link
Member

Since we copy the query parameter map in a couple places this might be possible but you need to provide a reproducible example.

@AlexV525
Copy link
Member

Please attach a reproducible example so we may take further investigations.

@AlexV525 AlexV525 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 19, 2024
@AlexV525 AlexV525 removed the h: need more info Further information is requested label Mar 19, 2024
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