aws-amplify / amplify-flutter

A declarative library with an easy-to-use interface for building Flutter applications on AWS.
https://docs.amplify.aws
Apache License 2.0
1.31k stars 243 forks source link

DataStoreException: Error in querying the model. Excepted a boolean but was NUMBER #1219

Closed WalterWoshid closed 2 years ago

WalterWoshid commented 2 years ago

Describe the bug Querying for a model which has a nullable boolean returns a DataStoreException. The model does not exist yet.

Checking the dynamoDB database shows no missing values which are not true|false|null.

Exception Message ``` E/amplify:flutter:datastore( 8511): Query operation failed. E/amplify:flutter:datastore( 8511): DataStoreException{message=Error in querying the model., cause=DataStoreException{message=Error converting field "wantsVerification" from model "UserProfile", cause=java.lang.IllegalStateException: Expected a boolean but was NUMBER at line 1 column 2 path $, recoverySuggestion=There is a possibility that there is a bug if this error persists. Please take a look at E/amplify:flutter:datastore( 8511): https://github.com/aws-amplify/amplify-android/issues to see if there are any existing issues that E/amplify:flutter:datastore( 8511): match your scenario, and file an issue with the details of the bug if there isn't.}, recoverySuggestion=See attached exception for details.} E/amplify:flutter:datastore( 8511): at com.amplifyframework.datastore.storage.sqlite.SQLiteStorageAdapter.lambda$query$5$SQLiteStorageAdapter(SQLiteStorageAdapter.java:448) E/amplify:flutter:datastore( 8511): at com.amplifyframework.datastore.storage.sqlite.-$$Lambda$SQLiteStorageAdapter$YrR7B1Rj3JmC_omOKlzMTn0U5hM.run(Unknown Source:10) E/amplify:flutter:datastore( 8511): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462) E/amplify:flutter:datastore( 8511): at java.util.concurrent.FutureTask.run(FutureTask.java:266) E/amplify:flutter:datastore( 8511): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) E/amplify:flutter:datastore( 8511): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) E/amplify:flutter:datastore( 8511): at java.lang.Thread.run(Thread.java:923) E/amplify:flutter:datastore( 8511): Caused by: DataStoreException{message=Error converting field "wantsVerification" from model "UserProfile", cause=java.lang.IllegalStateException: Expected a boolean but was NUMBER at line 1 column 2 path $, recoverySuggestion=There is a possibility that there is a bug if this error persists. Please take a look at E/amplify:flutter:datastore( 8511): https://github.com/aws-amplify/amplify-android/issues to see if there are any existing issues that E/amplify:flutter:datastore( 8511): match your scenario, and file an issue with the details of the bug if there isn't.} E/amplify:flutter:datastore( 8511): at com.amplifyframework.datastore.storage.sqlite.SQLiteModelFieldTypeConverter.convertValueFromSource(SQLiteModelFieldTypeConverter.java:194) E/amplify:flutter:datastore( 8511): at com.amplifyframework.datastore.storage.sqlite.SQLiteModelFieldTypeConverter.buildMapForModel(SQLiteModelFieldTypeConverter.java:129) E/amplify:flutter:datastore( 8511): at com.amplifyframework.datastore.storage.sqlite.SQLiteStorageAdapter.lambda$query$5$SQLiteStorageAdapter(SQLiteStorageAdapter.java:441) E/amplify:flutter:datastore( 8511): ... 6 more E/amplify:flutter:datastore( 8511): Caused by: java.lang.IllegalStateException: Expected a boolean but was NUMBER at line 1 column 2 path $ E/amplify:flutter:datastore( 8511): at com.google.gson.stream.JsonReader.nextBoolean(JsonReader.java:854) E/amplify:flutter:datastore( 8511): at com.google.gson.internal.bind.TypeAdapters$3.read(TypeAdapters.java:144) E/amplify:flutter:datastore( 8511): at com.google.gson.internal.bind.TypeAdapters$3.read(TypeAdapters.java:133) E/amplify:flutter:datastore( 8511): at com.google.gson.TypeAdapter.fromJson(TypeAdapter.java:260) E/amplify:flutter:datastore( 8511): at com.google.gson.TypeAdapter.fromJson(TypeAdapter.java:273) E/amplify:flutter:datastore( 8511): at com.amplifyframework.datastore.storage.sqlite.SQLiteModelFieldTypeConverter.convertCustomTypeToTarget(SQLiteModelFieldTypeConverter.java:217) E/amplify:flutter:datastore( 8511): at com.amplifyframework.datastore.storage.sqlite.SQLiteModelFieldTypeConverter.convertValueFromSource(SQLiteModelFieldTypeConverter.java:169) E/amplify:flutter:datastore( 8511): ... 8 more ```
Output of flutter doctor -v ``` [√] Flutter (Channel stable, 2.5.1, on Microsoft Windows [Version 10.0.19043.1348], locale de-DE) • Flutter version 2.5.1 at C:\Flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision ffb2ecea52 (3 months ago), 2021-09-17 15:26:33 -0400 • Engine revision b3af521a05 • Dart version 2.14.2 [√] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at C:\Android\Sdk • Platform android-31, build-tools 31.0.0 • ANDROID_SDK_ROOT = C:\Android\Sdk • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [√] Android Studio (version 2020.3) • Android Studio at C:\Program Files\Android\Android Studio • 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 11.0.10+0-b96-7249189) [√] VS Code (version 1.62.3) • VS Code at C:\Users\Walter\AppData\Local\Programs\Microsoft VS Code • Flutter extension can be installed from: https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter [√] Connected device (3 available) • Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator) • Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.45 • Edge (web) • edge • web-javascript • Microsoft Edge 96.0.1054.53 • No issues found! ```
Dependencies (pubspec.lock) ``` # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: amplify_analytics_plugin_interface: dependency: transitive description: name: amplify_analytics_plugin_interface url: "https://pub.dartlang.org" source: hosted version: "0.2.10" amplify_api: dependency: "direct main" description: name: amplify_api url: "https://pub.dartlang.org" source: hosted version: "0.2.10" amplify_api_plugin_interface: dependency: transitive description: name: amplify_api_plugin_interface url: "https://pub.dartlang.org" source: hosted version: "0.2.10" amplify_auth_cognito: dependency: "direct main" description: name: amplify_auth_cognito url: "https://pub.dartlang.org" source: hosted version: "0.2.10" amplify_auth_plugin_interface: dependency: transitive description: name: amplify_auth_plugin_interface url: "https://pub.dartlang.org" source: hosted version: "0.2.10" amplify_core: dependency: transitive description: name: amplify_core url: "https://pub.dartlang.org" source: hosted version: "0.2.10" amplify_datastore: dependency: "direct main" description: name: amplify_datastore url: "https://pub.dartlang.org" source: hosted version: "0.2.10" amplify_datastore_plugin_interface: dependency: transitive description: name: amplify_datastore_plugin_interface url: "https://pub.dartlang.org" source: hosted version: "0.2.10" amplify_flutter: dependency: "direct main" description: name: amplify_flutter url: "https://pub.dartlang.org" source: hosted version: "0.2.10" amplify_storage_plugin_interface: dependency: transitive description: name: amplify_storage_plugin_interface url: "https://pub.dartlang.org" source: hosted version: "0.2.10" amplify_storage_s3: dependency: "direct main" description: name: amplify_storage_s3 url: "https://pub.dartlang.org" source: hosted version: "0.2.10" android_path_provider: dependency: "direct main" description: name: android_path_provider url: "https://pub.dartlang.org" source: hosted version: "0.3.0" archive: dependency: transitive description: name: archive url: "https://pub.dartlang.org" source: hosted version: "3.1.2" args: dependency: transitive description: name: args url: "https://pub.dartlang.org" source: hosted version: "2.2.0" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted version: "2.8.1" bloc: dependency: transitive description: name: bloc url: "https://pub.dartlang.org" source: hosted version: "7.2.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted version: "2.1.0" cached_network_image: dependency: "direct main" description: name: cached_network_image url: "https://pub.dartlang.org" source: hosted version: "3.1.0" cached_network_image_platform_interface: dependency: transitive description: name: cached_network_image_platform_interface url: "https://pub.dartlang.org" source: hosted version: "1.0.0" cached_network_image_web: dependency: transitive description: name: cached_network_image_web url: "https://pub.dartlang.org" source: hosted version: "1.0.1" camera: dependency: "direct main" description: name: camera url: "https://pub.dartlang.org" source: hosted version: "0.9.4+5" camera_platform_interface: dependency: transitive description: name: camera_platform_interface url: "https://pub.dartlang.org" source: hosted version: "2.1.1" camera_web: dependency: transitive description: name: camera_web url: "https://pub.dartlang.org" source: hosted version: "0.2.1+1" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted version: "1.3.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted version: "1.15.0" cross_file: dependency: transitive description: name: cross_file url: "https://pub.dartlang.org" source: hosted version: "0.3.1+4" crypto: dependency: transitive description: name: crypto url: "https://pub.dartlang.org" source: hosted version: "3.0.1" cupertino_icons: dependency: "direct main" description: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted version: "1.0.3" date_time_format: dependency: transitive description: name: date_time_format url: "https://pub.dartlang.org" source: hosted version: "2.0.1" dbus: dependency: transitive description: name: dbus url: "https://pub.dartlang.org" source: hosted version: "0.5.6" equatable: dependency: "direct main" description: name: equatable url: "https://pub.dartlang.org" source: hosted version: "2.0.3" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted version: "1.2.0" ffi: dependency: transitive description: name: ffi url: "https://pub.dartlang.org" source: hosted version: "1.1.2" file: dependency: transitive description: name: file url: "https://pub.dartlang.org" source: hosted version: "6.1.2" file_picker: dependency: "direct main" description: name: file_picker url: "https://pub.dartlang.org" source: hosted version: "4.1.6" file_saver: dependency: "direct main" description: name: file_saver url: "https://pub.dartlang.org" source: hosted version: "0.0.10" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" flutter_bloc: dependency: "direct main" description: name: flutter_bloc url: "https://pub.dartlang.org" source: hosted version: "7.3.3" flutter_blurhash: dependency: transitive description: name: flutter_blurhash url: "https://pub.dartlang.org" source: hosted version: "0.6.0" flutter_cache_manager: dependency: transitive description: name: flutter_cache_manager url: "https://pub.dartlang.org" source: hosted version: "3.1.2" flutter_launcher_icons: dependency: "direct dev" description: name: flutter_launcher_icons url: "https://pub.dartlang.org" source: hosted version: "0.9.2" flutter_local_notifications: dependency: "direct main" description: name: flutter_local_notifications url: "https://pub.dartlang.org" source: hosted version: "9.1.0" flutter_local_notifications_linux: dependency: transitive description: name: flutter_local_notifications_linux url: "https://pub.dartlang.org" source: hosted version: "0.3.0" flutter_local_notifications_platform_interface: dependency: transitive description: name: flutter_local_notifications_platform_interface url: "https://pub.dartlang.org" source: hosted version: "5.0.0" flutter_pdfview: dependency: "direct main" description: name: flutter_pdfview url: "https://pub.dartlang.org" source: hosted version: "1.2.1" flutter_plugin_android_lifecycle: dependency: transitive description: name: flutter_plugin_android_lifecycle url: "https://pub.dartlang.org" source: hosted version: "2.0.2" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" flutter_web_plugins: dependency: transitive description: flutter source: sdk version: "0.0.0" http: dependency: transitive description: name: http url: "https://pub.dartlang.org" source: hosted version: "0.13.3" http_parser: dependency: transitive description: name: http_parser url: "https://pub.dartlang.org" source: hosted version: "4.0.0" image: dependency: transitive description: name: image url: "https://pub.dartlang.org" source: hosted version: "3.0.2" image_cropping: dependency: "direct main" description: name: image_cropping url: "https://pub.dartlang.org" source: hosted version: "0.0.7" image_picker: dependency: "direct main" description: name: image_picker url: "https://pub.dartlang.org" source: hosted version: "0.8.3" image_picker_for_web: dependency: transitive description: name: image_picker_for_web url: "https://pub.dartlang.org" source: hosted version: "2.1.2" image_picker_platform_interface: dependency: transitive description: name: image_picker_platform_interface url: "https://pub.dartlang.org" source: hosted version: "2.2.0" intl: dependency: "direct main" description: name: intl url: "https://pub.dartlang.org" source: hosted version: "0.17.0" js: dependency: transitive description: name: js url: "https://pub.dartlang.org" source: hosted version: "0.6.3" lint: dependency: "direct main" description: name: lint url: "https://pub.dartlang.org" source: hosted version: "1.7.2" loader_overlay: dependency: "direct main" description: name: loader_overlay url: "https://pub.dartlang.org" source: hosted version: "2.0.2+1" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted version: "1.7.0" nested: dependency: transitive description: name: nested url: "https://pub.dartlang.org" source: hosted version: "1.0.0" octo_image: dependency: transitive description: name: octo_image url: "https://pub.dartlang.org" source: hosted version: "1.0.0+1" open_file: dependency: "direct main" description: name: open_file url: "https://pub.dartlang.org" source: hosted version: "3.2.1" package_info_plus: dependency: "direct main" description: name: package_info_plus url: "https://pub.dartlang.org" source: hosted version: "1.0.6" package_info_plus_linux: dependency: transitive description: name: package_info_plus_linux url: "https://pub.dartlang.org" source: hosted version: "1.0.3" package_info_plus_macos: dependency: transitive description: name: package_info_plus_macos url: "https://pub.dartlang.org" source: hosted version: "1.1.1" package_info_plus_platform_interface: dependency: transitive description: name: package_info_plus_platform_interface url: "https://pub.dartlang.org" source: hosted version: "1.0.2" package_info_plus_web: dependency: transitive description: name: package_info_plus_web url: "https://pub.dartlang.org" source: hosted version: "1.0.4" package_info_plus_windows: dependency: transitive description: name: package_info_plus_windows url: "https://pub.dartlang.org" source: hosted version: "1.0.3" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted version: "1.8.0" path_provider: dependency: "direct main" description: name: path_provider url: "https://pub.dartlang.org" source: hosted version: "2.0.2" path_provider_linux: dependency: transitive description: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted version: "2.0.2" path_provider_macos: dependency: transitive description: name: path_provider_macos url: "https://pub.dartlang.org" source: hosted version: "2.0.2" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted version: "2.0.1" path_provider_windows: dependency: transitive description: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted version: "2.0.3" pedantic: dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" source: hosted version: "1.11.1" permission_handler: dependency: "direct main" description: name: permission_handler url: "https://pub.dartlang.org" source: hosted version: "8.1.4+2" permission_handler_platform_interface: dependency: transitive description: name: permission_handler_platform_interface url: "https://pub.dartlang.org" source: hosted version: "3.6.1" petitparser: dependency: transitive description: name: petitparser url: "https://pub.dartlang.org" source: hosted version: "4.1.0" photo_view: dependency: "direct main" description: name: photo_view url: "https://pub.dartlang.org" source: hosted version: "0.13.0" pin_code_fields: dependency: "direct main" description: name: pin_code_fields url: "https://pub.dartlang.org" source: hosted version: "7.3.0" platform: dependency: transitive description: name: platform url: "https://pub.dartlang.org" source: hosted version: "3.0.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted version: "2.0.1" process: dependency: transitive description: name: process url: "https://pub.dartlang.org" source: hosted version: "4.2.3" provider: dependency: "direct main" description: name: provider url: "https://pub.dartlang.org" source: hosted version: "6.0.0" pull_to_refresh: dependency: "direct main" description: name: pull_to_refresh url: "https://pub.dartlang.org" source: hosted version: "2.0.0" quiver: dependency: "direct main" description: name: quiver url: "https://pub.dartlang.org" source: hosted version: "3.0.1" rxdart: dependency: transitive description: name: rxdart url: "https://pub.dartlang.org" source: hosted version: "0.27.2" sky_engine: dependency: transitive description: flutter source: sdk version: "0.0.99" source_span: dependency: transitive description: name: source_span url: "https://pub.dartlang.org" source: hosted version: "1.8.1" sqflite: dependency: transitive description: name: sqflite url: "https://pub.dartlang.org" source: hosted version: "2.0.0+4" sqflite_common: dependency: transitive description: name: sqflite_common url: "https://pub.dartlang.org" source: hosted version: "2.0.1+1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted version: "2.1.0" stream_transform: dependency: transitive description: name: stream_transform url: "https://pub.dartlang.org" source: hosted version: "2.0.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted version: "1.1.0" synchronized: dependency: transitive description: name: synchronized url: "https://pub.dartlang.org" source: hosted version: "3.0.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted version: "0.4.2" timezone: dependency: transitive description: name: timezone url: "https://pub.dartlang.org" source: hosted version: "0.8.0" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted version: "1.3.0" uni_links: dependency: "direct main" description: name: uni_links url: "https://pub.dartlang.org" source: hosted version: "0.5.1" uni_links_platform_interface: dependency: transitive description: name: uni_links_platform_interface url: "https://pub.dartlang.org" source: hosted version: "1.0.0" uni_links_web: dependency: transitive description: name: uni_links_web url: "https://pub.dartlang.org" source: hosted version: "0.1.0" url_launcher: dependency: "direct main" description: name: url_launcher url: "https://pub.dartlang.org" source: hosted version: "6.0.10" url_launcher_linux: dependency: transitive description: name: url_launcher_linux url: "https://pub.dartlang.org" source: hosted version: "2.0.2" url_launcher_macos: dependency: transitive description: name: url_launcher_macos url: "https://pub.dartlang.org" source: hosted version: "2.0.2" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface url: "https://pub.dartlang.org" source: hosted version: "2.0.4" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted version: "2.0.4" url_launcher_windows: dependency: transitive description: name: url_launcher_windows url: "https://pub.dartlang.org" source: hosted version: "2.0.2" uuid: dependency: transitive description: name: uuid url: "https://pub.dartlang.org" source: hosted version: "3.0.4" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted version: "2.1.0" win32: dependency: transitive description: name: win32 url: "https://pub.dartlang.org" source: hosted version: "2.2.5" xdg_directories: dependency: transitive description: name: xdg_directories url: "https://pub.dartlang.org" source: hosted version: "0.2.0" xml: dependency: transitive description: name: xml url: "https://pub.dartlang.org" source: hosted version: "5.1.2" yaml: dependency: transitive description: name: yaml url: "https://pub.dartlang.org" source: hosted version: "3.1.0" sdks: dart: ">=2.14.0 <3.0.0" flutter: ">=2.5.0" ```
HuiSF commented 2 years ago

Hi @WalterWoshid Thanks for reporting this issue.

What's the actual value of the wantsVerification field of the exact model that you were querying?

WalterWoshid commented 2 years ago

Hi @HuiSF

The actual model does not exist. It should return an empty list.

HuiSF commented 2 years ago

@WalterWoshid could you provide the model schema and code example that you are testing with?

WalterWoshid commented 2 years ago

Here you go @HuiSF:

Model Schema Dart ```dart /* * Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ // NOTE: This file is generated and may not follow lint rules defined in your app // Generated files can be excluded from analysis in analysis_options.yaml // For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis // ignore_for_file: public_member_api_docs, file_names, unnecessary_new, prefer_if_null_operators, prefer_const_constructors, slash_for_doc_comments, annotate_overrides, non_constant_identifier_names, unnecessary_string_interpolations, prefer_adjacent_string_concatenation, unnecessary_const, dead_code import 'ModelProvider.dart'; import 'package:amplify_datastore_plugin_interface/amplify_datastore_plugin_interface.dart'; import 'package:flutter/foundation.dart'; /** This is an auto generated class representing the UserProfile type in your schema. */ @immutable class UserProfile extends Model { static const classType = const _UserProfileModelType(); final String id; final String? _firstName; final String? _middleName; final String? _lastName; final TemporalDate? _birthdate; final String? _zipCode; final String? _city; final BankAccountType? _bankAccountType; final String? _iban; final String? _bic; final String? _bankName; final String? _bankOwner; final String? _cognitoUserID; final String? _fullStreetAddress; final TemporalDateTime? _createdAt; final String? _cognitoFileID; final Status? _adminVerified; final bool? _wantsVerification; final String? _militaryRank; final String? _boxAddress; final String? _postOfficeAddress; final String? _rejectedReason; final String? _bankUserFullName; final String? _bankUserAddress; final int? _accountNumber; final String? _typename; final bool? _onboarded; @override getInstanceType() => classType; @override String getId() { return id; } String? get firstName { return _firstName; } String? get middleName { return _middleName; } String? get lastName { return _lastName; } TemporalDate? get birthdate { return _birthdate; } String? get zipCode { return _zipCode; } String? get city { return _city; } BankAccountType? get bankAccountType { return _bankAccountType; } String? get iban { return _iban; } String? get bic { return _bic; } String? get bankName { return _bankName; } String? get bankOwner { return _bankOwner; } String get cognitoUserID { try { return _cognitoUserID!; } catch(e) { throw new DataStoreException(DataStoreExceptionMessages.codeGenRequiredFieldForceCastExceptionMessage, recoverySuggestion: DataStoreExceptionMessages.codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } } String? get fullStreetAddress { return _fullStreetAddress; } TemporalDateTime? get createdAt { return _createdAt; } String? get cognitoFileID { return _cognitoFileID; } Status get adminVerified { try { return _adminVerified!; } catch(e) { throw new DataStoreException(DataStoreExceptionMessages.codeGenRequiredFieldForceCastExceptionMessage, recoverySuggestion: DataStoreExceptionMessages.codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } } bool? get wantsVerification { return _wantsVerification; } String? get militaryRank { return _militaryRank; } String? get boxAddress { return _boxAddress; } String? get postOfficeAddress { return _postOfficeAddress; } String? get rejectedReason { return _rejectedReason; } String? get bankUserFullName { return _bankUserFullName; } String? get bankUserAddress { return _bankUserAddress; } int? get accountNumber { return _accountNumber; } String? get typename { return _typename; } bool? get onboarded { return _onboarded; } const UserProfile._internal({required this.id, firstName, middleName, lastName, birthdate, zipCode, city, bankAccountType, iban, bic, bankName, bankOwner, required cognitoUserID, fullStreetAddress, createdAt, cognitoFileID, required adminVerified, wantsVerification, militaryRank, boxAddress, postOfficeAddress, rejectedReason, bankUserFullName, bankUserAddress, accountNumber, typename, onboarded}): _firstName = firstName, _middleName = middleName, _lastName = lastName, _birthdate = birthdate, _zipCode = zipCode, _city = city, _bankAccountType = bankAccountType, _iban = iban, _bic = bic, _bankName = bankName, _bankOwner = bankOwner, _cognitoUserID = cognitoUserID, _fullStreetAddress = fullStreetAddress, _createdAt = createdAt, _cognitoFileID = cognitoFileID, _adminVerified = adminVerified, _wantsVerification = wantsVerification, _militaryRank = militaryRank, _boxAddress = boxAddress, _postOfficeAddress = postOfficeAddress, _rejectedReason = rejectedReason, _bankUserFullName = bankUserFullName, _bankUserAddress = bankUserAddress, _accountNumber = accountNumber, _typename = typename, _onboarded = onboarded; factory UserProfile({String? id, String? firstName, String? middleName, String? lastName, TemporalDate? birthdate, String? zipCode, String? city, BankAccountType? bankAccountType, String? iban, String? bic, String? bankName, String? bankOwner, required String cognitoUserID, String? fullStreetAddress, TemporalDateTime? createdAt, String? cognitoFileID, required Status adminVerified, bool? wantsVerification, String? militaryRank, String? boxAddress, String? postOfficeAddress, String? rejectedReason, String? bankUserFullName, String? bankUserAddress, int? accountNumber, String? typename, bool? onboarded}) { return UserProfile._internal( id: id == null ? UUID.getUUID() : id, firstName: firstName, middleName: middleName, lastName: lastName, birthdate: birthdate, zipCode: zipCode, city: city, bankAccountType: bankAccountType, iban: iban, bic: bic, bankName: bankName, bankOwner: bankOwner, cognitoUserID: cognitoUserID, fullStreetAddress: fullStreetAddress, createdAt: createdAt, cognitoFileID: cognitoFileID, adminVerified: adminVerified, wantsVerification: wantsVerification, militaryRank: militaryRank, boxAddress: boxAddress, postOfficeAddress: postOfficeAddress, rejectedReason: rejectedReason, bankUserFullName: bankUserFullName, bankUserAddress: bankUserAddress, accountNumber: accountNumber, typename: typename, onboarded: onboarded); } bool equals(Object other) { return this == other; } @override bool operator ==(Object other) { if (identical(other, this)) return true; return other is UserProfile && id == other.id && _firstName == other._firstName && _middleName == other._middleName && _lastName == other._lastName && _birthdate == other._birthdate && _zipCode == other._zipCode && _city == other._city && _bankAccountType == other._bankAccountType && _iban == other._iban && _bic == other._bic && _bankName == other._bankName && _bankOwner == other._bankOwner && _cognitoUserID == other._cognitoUserID && _fullStreetAddress == other._fullStreetAddress && _createdAt == other._createdAt && _cognitoFileID == other._cognitoFileID && _adminVerified == other._adminVerified && _wantsVerification == other._wantsVerification && _militaryRank == other._militaryRank && _boxAddress == other._boxAddress && _postOfficeAddress == other._postOfficeAddress && _rejectedReason == other._rejectedReason && _bankUserFullName == other._bankUserFullName && _bankUserAddress == other._bankUserAddress && _accountNumber == other._accountNumber && _typename == other._typename && _onboarded == other._onboarded; } @override int get hashCode => toString().hashCode; @override String toString() { var buffer = new StringBuffer(); buffer.write("UserProfile {"); buffer.write("id=" + "$id" + ", "); buffer.write("firstName=" + "$_firstName" + ", "); buffer.write("middleName=" + "$_middleName" + ", "); buffer.write("lastName=" + "$_lastName" + ", "); buffer.write("birthdate=" + (_birthdate != null ? _birthdate!.format() : "null") + ", "); buffer.write("zipCode=" + "$_zipCode" + ", "); buffer.write("city=" + "$_city" + ", "); buffer.write("bankAccountType=" + (_bankAccountType != null ? enumToString(_bankAccountType)! : "null") + ", "); buffer.write("iban=" + "$_iban" + ", "); buffer.write("bic=" + "$_bic" + ", "); buffer.write("bankName=" + "$_bankName" + ", "); buffer.write("bankOwner=" + "$_bankOwner" + ", "); buffer.write("cognitoUserID=" + "$_cognitoUserID" + ", "); buffer.write("fullStreetAddress=" + "$_fullStreetAddress" + ", "); buffer.write("createdAt=" + (_createdAt != null ? _createdAt!.format() : "null") + ", "); buffer.write("cognitoFileID=" + "$_cognitoFileID" + ", "); buffer.write("adminVerified=" + (_adminVerified != null ? enumToString(_adminVerified)! : "null") + ", "); buffer.write("wantsVerification=" + (_wantsVerification != null ? _wantsVerification!.toString() : "null") + ", "); buffer.write("militaryRank=" + "$_militaryRank" + ", "); buffer.write("boxAddress=" + "$_boxAddress" + ", "); buffer.write("postOfficeAddress=" + "$_postOfficeAddress" + ", "); buffer.write("rejectedReason=" + "$_rejectedReason" + ", "); buffer.write("bankUserFullName=" + "$_bankUserFullName" + ", "); buffer.write("bankUserAddress=" + "$_bankUserAddress" + ", "); buffer.write("accountNumber=" + (_accountNumber != null ? _accountNumber!.toString() : "null") + ", "); buffer.write("typename=" + "$_typename" + ", "); buffer.write("onboarded=" + (_onboarded != null ? _onboarded!.toString() : "null")); buffer.write("}"); return buffer.toString(); } UserProfile copyWith({String? id, String? firstName, String? middleName, String? lastName, TemporalDate? birthdate, String? zipCode, String? city, BankAccountType? bankAccountType, String? iban, String? bic, String? bankName, String? bankOwner, String? cognitoUserID, String? fullStreetAddress, TemporalDateTime? createdAt, String? cognitoFileID, Status? adminVerified, bool? wantsVerification, String? militaryRank, String? boxAddress, String? postOfficeAddress, String? rejectedReason, String? bankUserFullName, String? bankUserAddress, int? accountNumber, String? typename, bool? onboarded}) { return UserProfile( id: id ?? this.id, firstName: firstName ?? this.firstName, middleName: middleName ?? this.middleName, lastName: lastName ?? this.lastName, birthdate: birthdate ?? this.birthdate, zipCode: zipCode ?? this.zipCode, city: city ?? this.city, bankAccountType: bankAccountType ?? this.bankAccountType, iban: iban ?? this.iban, bic: bic ?? this.bic, bankName: bankName ?? this.bankName, bankOwner: bankOwner ?? this.bankOwner, cognitoUserID: cognitoUserID ?? this.cognitoUserID, fullStreetAddress: fullStreetAddress ?? this.fullStreetAddress, createdAt: createdAt ?? this.createdAt, cognitoFileID: cognitoFileID ?? this.cognitoFileID, adminVerified: adminVerified ?? this.adminVerified, wantsVerification: wantsVerification ?? this.wantsVerification, militaryRank: militaryRank ?? this.militaryRank, boxAddress: boxAddress ?? this.boxAddress, postOfficeAddress: postOfficeAddress ?? this.postOfficeAddress, rejectedReason: rejectedReason ?? this.rejectedReason, bankUserFullName: bankUserFullName ?? this.bankUserFullName, bankUserAddress: bankUserAddress ?? this.bankUserAddress, accountNumber: accountNumber ?? this.accountNumber, typename: typename ?? this.typename, onboarded: onboarded ?? this.onboarded); } UserProfile.fromJson(Map json) : id = json['id'], _firstName = json['firstName'], _middleName = json['middleName'], _lastName = json['lastName'], _birthdate = json['birthdate'] != null ? TemporalDate.fromString(json['birthdate']) : null, _zipCode = json['zipCode'], _city = json['city'], _bankAccountType = enumFromString(json['bankAccountType'], BankAccountType.values), _iban = json['iban'], _bic = json['bic'], _bankName = json['bankName'], _bankOwner = json['bankOwner'], _cognitoUserID = json['cognitoUserID'], _fullStreetAddress = json['fullStreetAddress'], _createdAt = json['createdAt'] != null ? TemporalDateTime.fromString(json['createdAt']) : null, _cognitoFileID = json['cognitoFileID'], _adminVerified = enumFromString(json['adminVerified'], Status.values), _wantsVerification = json['wantsVerification'], _militaryRank = json['militaryRank'], _boxAddress = json['boxAddress'], _postOfficeAddress = json['postOfficeAddress'], _rejectedReason = json['rejectedReason'], _bankUserFullName = json['bankUserFullName'], _bankUserAddress = json['bankUserAddress'], _accountNumber = (json['accountNumber'] as num?)?.toInt(), _typename = json['typename'], _onboarded = json['onboarded']; Map toJson() => { 'id': id, 'firstName': _firstName, 'middleName': _middleName, 'lastName': _lastName, 'birthdate': _birthdate?.format(), 'zipCode': _zipCode, 'city': _city, 'bankAccountType': enumToString(_bankAccountType), 'iban': _iban, 'bic': _bic, 'bankName': _bankName, 'bankOwner': _bankOwner, 'cognitoUserID': _cognitoUserID, 'fullStreetAddress': _fullStreetAddress, 'createdAt': _createdAt?.format(), 'cognitoFileID': _cognitoFileID, 'adminVerified': enumToString(_adminVerified), 'wantsVerification': _wantsVerification, 'militaryRank': _militaryRank, 'boxAddress': _boxAddress, 'postOfficeAddress': _postOfficeAddress, 'rejectedReason': _rejectedReason, 'bankUserFullName': _bankUserFullName, 'bankUserAddress': _bankUserAddress, 'accountNumber': _accountNumber, 'typename': _typename, 'onboarded': _onboarded }; static final QueryField ID = QueryField(fieldName: "userProfile.id"); static final QueryField FIRSTNAME = QueryField(fieldName: "firstName"); static final QueryField MIDDLENAME = QueryField(fieldName: "middleName"); static final QueryField LASTNAME = QueryField(fieldName: "lastName"); static final QueryField BIRTHDATE = QueryField(fieldName: "birthdate"); static final QueryField ZIPCODE = QueryField(fieldName: "zipCode"); static final QueryField CITY = QueryField(fieldName: "city"); static final QueryField BANKACCOUNTTYPE = QueryField(fieldName: "bankAccountType"); static final QueryField IBAN = QueryField(fieldName: "iban"); static final QueryField BIC = QueryField(fieldName: "bic"); static final QueryField BANKNAME = QueryField(fieldName: "bankName"); static final QueryField BANKOWNER = QueryField(fieldName: "bankOwner"); static final QueryField COGNITOUSERID = QueryField(fieldName: "cognitoUserID"); static final QueryField FULLSTREETADDRESS = QueryField(fieldName: "fullStreetAddress"); static final QueryField CREATEDAT = QueryField(fieldName: "createdAt"); static final QueryField COGNITOFILEID = QueryField(fieldName: "cognitoFileID"); static final QueryField ADMINVERIFIED = QueryField(fieldName: "adminVerified"); static final QueryField WANTSVERIFICATION = QueryField(fieldName: "wantsVerification"); static final QueryField MILITARYRANK = QueryField(fieldName: "militaryRank"); static final QueryField BOXADDRESS = QueryField(fieldName: "boxAddress"); static final QueryField POSTOFFICEADDRESS = QueryField(fieldName: "postOfficeAddress"); static final QueryField REJECTEDREASON = QueryField(fieldName: "rejectedReason"); static final QueryField BANKUSERFULLNAME = QueryField(fieldName: "bankUserFullName"); static final QueryField BANKUSERADDRESS = QueryField(fieldName: "bankUserAddress"); static final QueryField ACCOUNTNUMBER = QueryField(fieldName: "accountNumber"); static final QueryField TYPENAME = QueryField(fieldName: "typename"); static final QueryField ONBOARDED = QueryField(fieldName: "onboarded"); static var schema = Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "UserProfile"; modelSchemaDefinition.pluralName = "UserProfiles"; modelSchemaDefinition.authRules = [ AuthRule( authStrategy: AuthStrategy.OWNER, ownerField: "owner", identityClaim: "cognito:username", operations: [ ModelOperation.CREATE, ModelOperation.UPDATE, ModelOperation.DELETE, ModelOperation.READ ]), AuthRule( authStrategy: AuthStrategy.PUBLIC, operations: [ ModelOperation.CREATE, ModelOperation.READ, ModelOperation.UPDATE ]), AuthRule( authStrategy: AuthStrategy.GROUPS, groupClaim: "cognito:groups", groups: [ "admin" ], operations: [ ModelOperation.READ, ModelOperation.CREATE, ModelOperation.UPDATE, ModelOperation.DELETE ]) ]; modelSchemaDefinition.addField(ModelFieldDefinition.id()); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.FIRSTNAME, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.string) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.MIDDLENAME, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.string) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.LASTNAME, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.string) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.BIRTHDATE, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.date) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.ZIPCODE, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.string) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.CITY, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.string) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.BANKACCOUNTTYPE, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.enumeration) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.IBAN, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.string) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.BIC, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.string) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.BANKNAME, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.string) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.BANKOWNER, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.string) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.COGNITOUSERID, isRequired: true, ofType: ModelFieldType(ModelFieldTypeEnum.string) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.FULLSTREETADDRESS, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.string) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.CREATEDAT, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.dateTime) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.COGNITOFILEID, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.string) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.ADMINVERIFIED, isRequired: true, ofType: ModelFieldType(ModelFieldTypeEnum.enumeration) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.WANTSVERIFICATION, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.bool) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.MILITARYRANK, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.string) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.BOXADDRESS, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.string) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.POSTOFFICEADDRESS, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.string) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.REJECTEDREASON, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.string) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.BANKUSERFULLNAME, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.string) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.BANKUSERADDRESS, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.string) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.ACCOUNTNUMBER, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.int) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.TYPENAME, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.string) )); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: UserProfile.ONBOARDED, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.bool) )); }); } class _UserProfileModelType extends ModelType { const _UserProfileModelType(); @override UserProfile fromJson(Map jsonData) { return UserProfile.fromJson(jsonData); } } ```
Code example ```dart List profilesList = []; try { profilesList = await Amplify.DataStore.query( UserProfile.classType, where: UserProfile.COGNITOUSERID.eq(cognitoId), ); } on Exception catch (e) { devLog('Could not fetch UserProfile. Reason: $e'); return null; } ```
HuiSF commented 2 years ago

@WalterWoshid looking at the exception log, it seemed that the query actually got some data back, and the logic was trying to convert local DB data into model instance.

Have you written any data of UserProfile into by invoking Amplify.DataStore.save?

Could you try to delete the test App, clean build and reinstall? Also, is BankAccountType another Model?

I will try to reproduce on my end in the meantime.

HuiSF commented 2 years ago

Are BankAccountType and Status Model or CustomType? (CustomType is not supported by 0.2.x)

WalterWoshid commented 2 years ago

@HuiSF Both are Enum Models

WalterWoshid commented 2 years ago

I am also receiving this exception when trying to save the model "UserProfile" and also this issue happens on initial app start: #802

Exception ``` W/amplify:aws-datastore( 3481): Failed to publish a local change = PendingMutation{mutatedItem=SerializedModel{id='82320cb5-c2b6-4e2b-b644-fdb753e3c8b9', serializedData={firstName=ValTest, wantsVerification=true, id=82320cb5-c2b6-4e2b-b644-fdb753e3c8b9}, modelName=UserProfile}, mutationType=UPDATE, mutationId=7961c163-5ed4-11ec-98a2-11b5db34e1c0, predicate=MatchAllQueryPredicate} W/amplify:aws-datastore( 3481): DataStoreException{message=Wanted 1 metadata for item with id = 82320cb5-c2b6-4e2b-b644-fdb753e3c8b9, but had 0., cause=null, recoverySuggestion=This is likely a bug. please report to AWS.} W/amplify:aws-datastore( 3481): at com.amplifyframework.datastore.syncengine.VersionRepository.extractVersion(VersionRepository.java:86) W/amplify:aws-datastore( 3481): at com.amplifyframework.datastore.syncengine.VersionRepository.lambda$null$0$VersionRepository(VersionRepository.java:60) W/amplify:aws-datastore( 3481): at com.amplifyframework.datastore.syncengine.-$$Lambda$VersionRepository$pDJF8PBRwphVueEHI3UosoRKGko.accept(Unknown Source:8) W/amplify:aws-datastore( 3481): at com.amplifyframework.datastore.storage.sqlite.SQLiteStorageAdapter.lambda$query$4$SQLiteStorageAdapter(SQLiteStorageAdapter.java:404) W/amplify:aws-datastore( 3481): at com.amplifyframework.datastore.storage.sqlite.-$$Lambda$SQLiteStorageAdapter$rGner20-W7t2tJu4yCrrZwlquWE.run(Unknown Source:10) W/amplify:aws-datastore( 3481): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462) W/amplify:aws-datastore( 3481): at java.util.concurrent.FutureTask.run(FutureTask.java:266) W/amplify:aws-datastore( 3481): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) W/amplify:aws-datastore( 3481): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) W/amplify:aws-datastore( 3481): at java.lang.Thread.run(Thread.java:923) W/amplify:aws-datastore( 3481): Error ended observation of mutation outbox: W/amplify:aws-datastore( 3481): java.lang.RuntimeException: DataStoreException{message=Wanted 1 metadata for item with id = 82320cb5-c2b6-4e2b-b644-fdb753e3c8b9, but had 0., cause=null, recoverySuggestion=This is likely a bug. please report to AWS.} W/amplify:aws-datastore( 3481): at io.reactivex.rxjava3.internal.util.ExceptionHelper.wrapOrThrow(ExceptionHelper.java:46) W/amplify:aws-datastore( 3481): at io.reactivex.rxjava3.internal.observers.BlockingMultiObserver.blockingAwait(BlockingMultiObserver.java:145) W/amplify:aws-datastore( 3481): at io.reactivex.rxjava3.core.Completable.blockingAwait(Completable.java:1490) W/amplify:aws-datastore( 3481): at com.amplifyframework.datastore.syncengine.MutationProcessor.drainMutationOutbox(MutationProcessor.java:117) W/amplify:aws-datastore( 3481): at com.amplifyframework.datastore.syncengine.MutationProcessor.lambda$startDrainingMutationOutbox$1$MutationProcessor(MutationProcessor.java:101) W/amplify:aws-datastore( 3481): at com.amplifyframework.datastore.syncengine.-$$Lambda$MutationProcessor$bjecRv6fl8W6Pcgjld1zB2NDYX8.apply(Unknown Source:4) W/amplify:aws-datastore( 3481): at io.reactivex.rxjava3.internal.operators.observable.ObservableFlatMapCompletableCompletable$FlatMapCompletableMainObserver.onNext(ObservableFlatMapCompletableCompletable.java:97) W/amplify:aws-datastore( 3481): at io.reactivex.rxjava3.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:201) W/amplify:aws-datastore( 3481): at io.reactivex.rxjava3.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:255) W/amplify:aws-datastore( 3481): at io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:65) W/amplify:aws-datastore( 3481): at io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:56) W/amplify:aws-datastore( 3481): at java.util.concurrent.FutureTask.run(FutureTask.java:266) W/amplify:aws-datastore( 3481): at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301) W/amplify:aws-datastore( 3481): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) W/amplify:aws-datastore( 3481): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) W/amplify:aws-datastore( 3481): at java.lang.Thread.run(Thread.java:923) W/amplify:aws-datastore( 3481): Caused by: DataStoreException{message=Wanted 1 metadata for item with id = 82320cb5-c2b6-4e2b-b644-fdb753e3c8b9, but had 0., cause=null, recoverySuggestion=This is likely a bug. please report to AWS.} W/amplify:aws-datastore( 3481): at com.amplifyframework.datastore.syncengine.VersionRepository.extractVersion(VersionRepository.java:86) W/amplify:aws-datastore( 3481): at com.amplifyframework.datastore.syncengine.VersionRepository.lambda$null$0$VersionRepository(VersionRepository.java:60) W/amplify:aws-datastore( 3481): at com.amplifyframework.datastore.syncengine.-$$Lambda$VersionRepository$pDJF8PBRwphVueEHI3UosoRKGko.accept(Unknown Source:8) W/amplify:aws-datastore( 3481): at com.amplifyframework.datastore.storage.sqlite.SQLiteStorageAdapter.lambda$query$4$SQLiteStorageAdapter(SQLiteStorageAdapter.java:404) W/amplify:aws-datastore( 3481): at com.amplifyframework.datastore.storage.sqlite.-$$Lambda$SQLiteStorageAdapter$rGner20-W7t2tJu4yCrrZwlquWE.run(Unknown Source:10) W/amplify:aws-datastore( 3481): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462) W/amplify:aws-datastore( 3481): at java.util.concurrent.FutureTask.run(FutureTask.java:266) W/amplify:aws-datastore( 3481): ... 3 more ```
HuiSF commented 2 years ago

Hi @WalterWoshid I couldn't reproduce this exact exception using the schema you provided in an Android emulator.

However, I did notice something wrong:

  1. The attached exception log indicates that the logic in amplify-android was trying to convert wantsVerification local DB value into Model field assuming its type as CustomType instead of BOOLEAN. This is a known issue (identified with issue https://github.com/aws-amplify/amplify-flutter/issues/752). The fix has been merged into the release-candidate branch. And available on the version 0.3.0-rc.3. Please try to use this version to correct the behavior.

  2. With the issue described above, boolean value is stored in local DB as TEXT, therefore it must be a string to be passed into the convert function, however, the exception indicates that a NUMBER values was passed. It looks like it got the value from a wrong column (there must be some data was written into the local DB of the App) This happens usually when local DB table schema is out of sync with the model schema

  3. The latest exception logs indicates the initial sync might have been interrupted, the metadata was not written into the local DB correctly. This may be caused by 2. (similar issues in amplify-android repo)

Here's my suggestion for next step:

  1. Try to upgrade 0.3.0-rc.3 version (please refer to the DataStore changelogs for migration)
  2. After upgrading run flutter clean then rebuild the App
  3. Remove the previously installed App from the testing device completely, and reinstall the newly built App
WalterWoshid commented 2 years ago

Hi @HuiSF

I don't know when this happened, but regenerating the models with "amplify codegen models" gives me this error

Missing concrete implementations of 'getter ModelProviderInterface.customTypeSchemas' and 'setter ModelProviderInterface.customTypeSchemas'.
Try implementing the missing methods, or make the class abstract

even though we don't use any custom types.

Adding this line to the ModelProvider: List<ModelSchema> customTypeSchemas = []; seems to fix this issue.

WalterWoshid commented 2 years ago

Sadly when I try to execute Amplify.DataStore.save(), it does not save the model, but executes the code as if nothing is wrong.

Some SLF4J error, that I solved before The console does print some lines though: ``` W/System.err( 6895): SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". W/System.err( 6895): SLF4J: Defaulting to no-operation (NOP) logger implementation W/System.err( 6895): SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. ``` Adding this to `build.gradle`: ```gradle dependencies { // ... implementation 'org.slf4j:slf4j-api:1.7.5' implementation 'org.slf4j:slf4j-log4j12:1.7.5' } ``` fixed it though, but the DataStore is still not syncing the data.

I noticed this error which was hidden in the console:

I/amplify:flutter:datastore( 9635): Unhandled DataStoreHubEvent: outboxMutationFailed
I/amplify:flutter:datastore( 9635): OutboxMutationFailedEvent{errorType=UNKNOWN, operation=CREATE, modelName=UserProfile, model=SerializedModel{id='326225d2-11b5-4af7-8978-6ed3b36c7ddb', serializedData={onboarded=null, lastName=null, zipCode=null, militaryRank=null, birthdate=null, city=null, bankName=null, bankOwner=null, boxAddress=null, createdAt=null, bankUserAddress=null, id=326225d2-11b5-4af7-8978-6ed3b36c7ddb, adminVerified=INREVIEW, bankUserFullName=null, postOfficeAddress=null, accountNumber=null, firstName=null, wantsVerification=null, bankAccountType=null, cognitoUserID=dc759375-f79c-465e-b6ae-14dc9aac322c, rejectedReason=null, cognitoFileID=null, iban=null, middleName=null, fullStreetAddress=null, bic=null, typename=UserProfile}, modelName=UserProfile}}
HuiSF commented 2 years ago

Hi @HuiSF

I don't know when this happened, but regenerating the models with "amplify codegen models" gives me this error


Missing concrete implementations of 'getter ModelProviderInterface.customTypeSchemas' and 'setter ModelProviderInterface.customTypeSchemas'.

Try implementing the missing methods, or make the class abstract

even though we don't use any custom types.

Adding this line to the ModelProvider: List<ModelSchema> customTypeSchemas = []; seems to fix this issue.

Hi @WalterWoshid if you are using the RC, please take a look at the DataStore change log, the RC require a special version of CLI, when you use this version of CLI, this error won't happen. Sorry I didn't clarify.

The Log4j error doesn't have any impact on model operation. But good to know you can fix it, I'll see if I can ask amplify-android to fix the error.

Regarding the failure on mutation out box, do you see any Java exception around it?

WalterWoshid commented 2 years ago

Hi @HuiSF

Thanks for the clarification about the CLI

Sadly there is no java exception around it

WalterWoshid commented 2 years ago

We finally fixed the bug. Apparently it was a second index on the UserProfile model which we had, added with NOSQL. I am not quite sure how it works, but removing it made it work again.

It has something to do with this article: https://docs.amplify.aws/cli/migration/transformer-migration/#changes-that-amplify-cli-will-auto-migrate-for-you

Anyways, thank you so much for you help! @HuiSF