Skip to content

fix: Dio error holds a reference to null values #825

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

Merged
merged 2 commits into from
Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/dart/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [3.1.14](https://github.com/parse-community/Parse-SDK-Flutter/compare/dart-3.1.13...dart-3.1.14) (2023-02-26)

### Bug Fixes

* Dio error object holds a reference to null values ([#774](https://github.com/parse-community/Parse-SDK-Flutter/issues/774))

## [3.1.13](https://github.com/parse-community/Parse-SDK-Flutter/compare/dart-3.1.12...dart-3.1.13) (2023-02-15)

### Bug Fixes
Expand Down Expand Up @@ -161,7 +167,7 @@ Bug fixes
## 1.0.22

Added dirty children
Added option of sembast or share_preferences
Added option of sembast or share_preferences

## 1.0.21

Expand All @@ -183,7 +189,7 @@ Bug fix

## 1.0.17

LiveQuery fix
LiveQuery fix
Bug fixes

## 1.0.16
Expand Down
2 changes: 1 addition & 1 deletion packages/dart/lib/src/base/parse_constants.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of flutter_parse_sdk;

// Library
const String keySdkVersion = '3.1.13';
const String keySdkVersion = '3.1.14';
const String keyLibraryName = 'Flutter Parse SDK';

// End Points
Expand Down
57 changes: 43 additions & 14 deletions packages/dart/lib/src/network/parse_dio_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ class ParseDioClient extends ParseClient {
path,
options: _Options(headers: options?.headers),
);

return ParseNetworkResponse(
data: dioResponse.data!, statusCode: dioResponse.statusCode!);
data: dioResponse.data!,
statusCode: dioResponse.statusCode!,
);
} on dio.DioError catch (error) {
return ParseNetworkResponse(
data: error.response?.data, statusCode: error.response!.statusCode!);
data: error.response?.data ?? _fallbackErrorData,
statusCode: error.response?.statusCode ?? ParseError.otherCause,
);
}
}

Expand All @@ -51,12 +56,15 @@ class ParseDioClient extends ParseClient {
headers: options?.headers, responseType: dio.ResponseType.bytes),
);
return ParseNetworkByteResponse(
bytes: dioResponse.data, statusCode: dioResponse.statusCode!);
bytes: dioResponse.data,
statusCode: dioResponse.statusCode!,
);
} on dio.DioError catch (error) {
if (error.response != null) {
return ParseNetworkByteResponse(
data: error.response?.data,
statusCode: error.response!.statusCode!);
data: error.response?.data ?? _fallbackErrorData,
statusCode: error.response?.statusCode ?? ParseError.otherCause,
);
} else {
return _getOtherCaseErrorForParseNetworkResponse(error.error);
}
Expand All @@ -72,11 +80,16 @@ class ParseDioClient extends ParseClient {
data: data,
options: _Options(headers: options?.headers),
);

return ParseNetworkResponse(
data: dioResponse.data!, statusCode: dioResponse.statusCode!);
data: dioResponse.data!,
statusCode: dioResponse.statusCode!,
);
} on dio.DioError catch (error) {
return ParseNetworkResponse(
data: error.response?.data, statusCode: error.response!.statusCode!);
data: error.response?.data ?? _fallbackErrorData,
statusCode: error.response?.statusCode ?? ParseError.otherCause,
);
}
}

Expand All @@ -89,11 +102,16 @@ class ParseDioClient extends ParseClient {
data: data,
options: _Options(headers: options?.headers),
);

return ParseNetworkResponse(
data: dioResponse.data!, statusCode: dioResponse.statusCode!);
data: dioResponse.data!,
statusCode: dioResponse.statusCode!,
);
} on dio.DioError catch (error) {
return ParseNetworkResponse(
data: error.response?.data, statusCode: error.response!.statusCode!);
data: error.response?.data ?? _fallbackErrorData,
statusCode: error.response?.statusCode ?? ParseError.otherCause,
);
}
}

Expand All @@ -111,13 +129,17 @@ class ParseDioClient extends ParseClient {
options: _Options(headers: options?.headers),
onSendProgress: onSendProgress,
);

return ParseNetworkResponse(
data: dioResponse.data!, statusCode: dioResponse.statusCode!);
data: dioResponse.data!,
statusCode: dioResponse.statusCode!,
);
} on dio.DioError catch (error) {
if (error.response != null) {
return ParseNetworkResponse(
data: error.response?.data,
statusCode: error.response!.statusCode!);
data: error.response?.data ?? _fallbackErrorData,
statusCode: error.response?.statusCode ?? ParseError.otherCause,
);
} else {
return _getOtherCaseErrorForParseNetworkResponse(error.error);
}
Expand All @@ -138,13 +160,20 @@ class ParseDioClient extends ParseClient {
path,
options: _Options(headers: options?.headers),
);

return ParseNetworkResponse(
data: dioResponse.data!, statusCode: dioResponse.statusCode!);
data: dioResponse.data!,
statusCode: dioResponse.statusCode!,
);
} on dio.DioError catch (error) {
return ParseNetworkResponse(
data: error.response?.data, statusCode: error.response!.statusCode!);
data: error.response?.data ?? _fallbackErrorData,
statusCode: error.response?.statusCode ?? ParseError.otherCause,
);
}
}

String get _fallbackErrorData => '{"$keyError":"NetworkError"}';
}

/// Creates a custom version of HTTP Client that has Parse Data Preset
Expand Down
2 changes: 1 addition & 1 deletion packages/dart/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: parse_server_sdk
description: Dart plugin for Parse Server, (https://parseplatform.org), (https://back4app.com)
version: 3.1.13
version: 3.1.14
homepage: https://github.com/parse-community/Parse-SDK-Flutter

environment:
Expand Down