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

Query predicates do not properly support lists for observeQuery() #1229

Closed
Abdelazeem777 opened this issue Dec 22, 2021 · 7 comments
Closed
Assignees
Labels
bug Something is not working; the issue has reproducible steps and has been reproduced datastore Issues related to the DataStore Category pending-release Issues that have been addressed in main but have not been released

Comments

@Abdelazeem777
Copy link

Abdelazeem777 commented Dec 22, 2021

Describe the bug
I am using observeQuery to get a stream for my changes on (Chat) table, every chat object contains usersInfo item which is a list of JSON.

So when any changes happen to this table I am getting this exception.

Unhandled Exception: type 'CastList<Object?, String>' is not a subtype of type 'String?' of 'other'

I think the problem is with your map casting executed with every chat item.

To Reproduce

  1. Just listen to any changes that happen to a table containing items with a list of AWSJSON using observeQuery.

  2. then you will get this exception:
    Unhandled Exception: type 'CastList<Object?, String>' is not a subtype of type 'String?' of 'other'

Expected behavior
Should return all changed objects without any exceptions.

Screenshots
Screenshot from 2021-12-22 12-29-59

Platform
Amplify Flutter current supports iOS and Android. This issue is reproducible in (check all that apply):
[x] Android
[x] iOS

Output of flutter doctor -v
  • Flutter version 2.8.0 at /home/abdelazeem/flutter
  • Upstream repository https://github.com/flutter/flutter
  • Framework revision cf44000065 (2 weeks ago), 2021-12-08 14:06:50 -0800
  • Engine revision 40a99c5951
  • Dart version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc5)
  • Android SDK at /home/abdelazeem/Android/Sdk
  • Platform android-31, build-tools 31.0.0-rc5
  • Java binary at: /snap/android-studio/current/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 google-chrome

[✓] Android Studio (version 2020.3)
  • Android Studio at /snap/android-studio/115/android-studio
  • Flutter plugin version 63.0.1
  • Dart plugin version 203.8452
  • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] Android Studio
  • Android Studio at /snap/android-studio/current/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
  • android-studio-dir = /snap/android-studio/current/android-studio
  • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] VS Code (version 1.62.3)
  • VS Code at /usr/share/code
  • Flutter extension version 3.29.0

[✓] Connected device (3 available)
  • Phantom6 Plus (mobile)             • 01800106C0800727 • android-arm64  • Android 7.1.1 (API 25)
  • Android SDK built for x86 (mobile) • emulator-5554    • android-x86    • Android 10 (API 29) (emulator)
  • Chrome (web)                       • chrome           • web-javascript • Google Chrome 96.0.4664.45

• No issues found!```

</details>

<details>

<summary>Dependencies (<code>pubspec.lock</code>)</summary>

Generated by pub

See https://dart.dev/tools/pub/glossary#lockfile

packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
url: "https://pub.dartlang.org"
source: hosted
version: "30.0.0"
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_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: "direct main"
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"
analyzer:
dependency: transitive
description:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "2.7.0"
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.6"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.0"
asn1lib:
dependency: transitive
description:
name: asn1lib
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.2"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
build:
dependency: transitive
description:
name: build
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
build_config:
dependency: transitive
description:
name: build_config
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
build_daemon:
dependency: transitive
description:
name: build_daemon
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
build_resolvers:
dependency: transitive
description:
name: build_resolvers
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
build_runner:
dependency: "direct dev"
description:
name: build_runner
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.5"
build_runner_core:
dependency: transitive
description:
name: build_runner_core
url: "https://pub.dartlang.org"
source: hosted
version: "7.2.2"
built_collection:
dependency: transitive
description:
name: built_collection
url: "https://pub.dartlang.org"
source: hosted
version: "5.1.1"
built_value:
dependency: transitive
description:
name: built_value
url: "https://pub.dartlang.org"
source: hosted
version: "8.1.3"
cached_network_image:
dependency: "direct main"
description:
name: cached_network_image
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0+1"
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"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
checked_yaml:
dependency: transitive
description:
name: checked_yaml
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
chewie:
dependency: transitive
description:
name: chewie
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
chewie_audio:
dependency: transitive
description:
name: chewie_audio
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
cli_util:
dependency: transitive
description:
name: cli_util
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.5"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
code_builder:
dependency: transitive
description:
name: code_builder
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
connectivity_plus:
dependency: "direct main"
description:
name: connectivity_plus
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
connectivity_plus_linux:
dependency: transitive
description:
name: connectivity_plus_linux
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
connectivity_plus_macos:
dependency: transitive
description:
name: connectivity_plus_macos
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.1"
connectivity_plus_platform_interface:
dependency: transitive
description:
name: connectivity_plus_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
connectivity_plus_web:
dependency: transitive
description:
name: connectivity_plus_web
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0+1"
connectivity_plus_windows:
dependency: transitive
description:
name: connectivity_plus_windows
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
cross_file:
dependency: transitive
description:
name: cross_file
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.2"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
csslib:
dependency: transitive
description:
name: csslib
url: "https://pub.dartlang.org"
source: hosted
version: "0.17.1"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
dart_style:
dependency: transitive
description:
name: dart_style
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
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.6.6"
device_frame:
dependency: transitive
description:
name: device_frame
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
device_info:
dependency: transitive
description:
name: device_info
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
device_info_platform_interface:
dependency: transitive
description:
name: device_info_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
device_preview:
dependency: "direct main"
description:
name: device_preview
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
dio:
dependency: "direct main"
description:
name: dio
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.4"
easy_localization:
dependency: "direct main"
description:
name: easy_localization
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
easy_logger:
dependency: transitive
description:
name: easy_logger
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.2"
encrypt:
dependency: "direct main"
description:
name: encrypt
url: "https://pub.dartlang.org"
source: hosted
version: "5.0.1"
equatable:
dependency: transitive
description:
name: equatable
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
extension:
dependency: transitive
description:
name: extension
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
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.2.5"
firebase:
dependency: transitive
description:
name: firebase
url: "https://pub.dartlang.org"
source: hosted
version: "9.0.2"
firebase_analytics:
dependency: "direct main"
description:
name: firebase_analytics
url: "https://pub.dartlang.org"
source: hosted
version: "8.3.4"
firebase_analytics_platform_interface:
dependency: transitive
description:
name: firebase_analytics_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
firebase_analytics_web:
dependency: transitive
description:
name: firebase_analytics_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0+1"
firebase_core:
dependency: "direct main"
description:
name: firebase_core
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0"
firebase_core_platform_interface:
dependency: transitive
description:
name: firebase_core_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.0"
firebase_core_web:
dependency: transitive
description:
name: firebase_core_web
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
firebase_messaging:
dependency: "direct main"
description:
name: firebase_messaging
url: "https://pub.dartlang.org"
source: hosted
version: "10.0.9"
firebase_messaging_platform_interface:
dependency: transitive
description:
name: firebase_messaging_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.9"
firebase_messaging_web:
dependency: transitive
description:
name: firebase_messaging_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
fixnum:
dependency: transitive
description:
name: fixnum
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_apns_only:
dependency: "direct main"
description:
path: "."
ref: HEAD
resolved-ref: b8293c68447d800e677c32597264f9e165a6fa21
url: "git://github.com/Abdelazeem777/flutter-apns"
source: git
version: "1.5.0-dev.1"
flutter_barcode_scanner:
dependency: "direct main"
description:
name: flutter_barcode_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
flutter_blurhash:
dependency: transitive
description:
name: flutter_blurhash
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.0"
flutter_cache_manager:
dependency: "direct main"
description:
name: flutter_cache_manager
url: "https://pub.dartlang.org"
source: hosted
version: "3.2.0"
flutter_facebook_auth:
dependency: "direct main"
description:
name: flutter_facebook_auth
url: "https://pub.dartlang.org"
source: hosted
version: "3.5.6"
flutter_facebook_auth_platform_interface:
dependency: transitive
description:
name: flutter_facebook_auth_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.7.0"
flutter_facebook_auth_web:
dependency: transitive
description:
name: flutter_facebook_auth_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.6.0+2"
flutter_html:
dependency: "direct main"
description:
name: flutter_html
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.1"
flutter_inappwebview:
dependency: "direct main"
description:
name: flutter_inappwebview
url: "https://pub.dartlang.org"
source: hosted
version: "5.3.2"
flutter_launcher_icons:
dependency: "direct dev"
description:
name: flutter_launcher_icons
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.2"
flutter_layout_grid:
dependency: transitive
description:
name: flutter_layout_grid
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
flutter_lints:
dependency: "direct dev"
description:
name: flutter_lints
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
flutter_local_notifications:
dependency: "direct main"
description:
name: flutter_local_notifications
url: "https://pub.dartlang.org"
source: hosted
version: "8.2.0"
flutter_local_notifications_platform_interface:
dependency: transitive
description:
name: flutter_local_notifications_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.1"
flutter_localizations:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
flutter_math_fork:
dependency: transitive
description:
name: flutter_math_fork
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.2+2"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
name: flutter_plugin_android_lifecycle
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
flutter_sound_lite:
dependency: "direct main"
description:
name: flutter_sound_lite
url: "https://pub.dartlang.org"
source: hosted
version: "8.4.2"
flutter_sound_platform_interface:
dependency: transitive
description:
name: flutter_sound_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "8.4.2"
flutter_sound_web:
dependency: transitive
description:
name: flutter_sound_web
url: "https://pub.dartlang.org"
source: hosted
version: "8.4.2"
flutter_svg:
dependency: "direct main"
description:
name: flutter_svg
url: "https://pub.dartlang.org"
source: hosted
version: "0.22.0"
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"
font_awesome_flutter:
dependency: "direct main"
description:
name: font_awesome_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "9.2.0"
freezed_annotation:
dependency: transitive
description:
name: freezed_annotation
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
frontend_server_client:
dependency: transitive
description:
name: frontend_server_client
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
glob:
dependency: transitive
description:
name: glob
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
google_sign_in:
dependency: "direct main"
description:
name: google_sign_in
url: "https://pub.dartlang.org"
source: hosted
version: "5.2.1"
google_sign_in_platform_interface:
dependency: transitive
description:
name: google_sign_in_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
google_sign_in_web:
dependency: transitive
description:
name: google_sign_in_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.0+3"
graphs:
dependency: transitive
description:
name: graphs
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
hive:
dependency: "direct main"
description:
name: hive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
hive_flutter:
dependency: "direct main"
description:
name: hive_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
hive_generator:
dependency: "direct dev"
description:
name: hive_generator
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
html:
dependency: transitive
description:
name: html
url: "https://pub.dartlang.org"
source: hosted
version: "0.15.0"
http:
dependency: transitive
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.4"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
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.8"
image_picker:
dependency: "direct main"
description:
name: image_picker
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.4+4"
image_picker_for_web:
dependency: transitive
description:
name: image_picker_for_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
image_picker_platform_interface:
dependency: transitive
description:
name: image_picker_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.1"
intl:
dependency: transitive
description:
name: intl
url: "https://pub.dartlang.org"
source: hosted
version: "0.17.0"
intl_phone_number_input:
dependency: "direct main"
description:
name: intl_phone_number_input
url: "https://pub.dartlang.org"
source: hosted
version: "0.7.0+2"
io:
dependency: transitive
description:
name: io
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
json_annotation:
dependency: transitive
description:
name: json_annotation
url: "https://pub.dartlang.org"
source: hosted
version: "4.4.0"
libphonenumber:
dependency: transitive
description:
name: libphonenumber
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
libphonenumber_platform_interface:
dependency: transitive
description:
name: libphonenumber_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.1"
libphonenumber_plugin:
dependency: transitive
description:
name: libphonenumber_plugin
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.3"
libphonenumber_web:
dependency: transitive
description:
name: libphonenumber_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0+1"
lints:
dependency: transitive
description:
name: lints
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
logger:
dependency: transitive
description:
name: logger
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
logging:
dependency: transitive
description:
name: logging
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
mime:
dependency: transitive
description:
name: mime
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
mockito:
dependency: "direct main"
description:
name: mockito
url: "https://pub.dartlang.org"
source: hosted
version: "5.0.16"
native_pdf_renderer:
dependency: transitive
description:
name: native_pdf_renderer
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
native_pdf_view:
dependency: "direct main"
description:
name: native_pdf_view
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.0"
nested:
dependency: transitive
description:
name: nested
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
nm:
dependency: transitive
description:
name: nm
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.1"
numerus:
dependency: transitive
description:
name: numerus
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
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_config:
dependency: transitive
description:
name: package_config
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
package_info_plus:
dependency: "direct main"
description:
name: package_info_plus
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
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.3.0"
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.4"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
path_drawing:
dependency: transitive
description:
name: path_drawing
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.1+1"
path_parsing:
dependency: transitive
description:
name: path_parsing
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.1"
path_provider:
dependency: transitive
description:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.7"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.9"
path_provider_ios:
dependency: transitive
description:
name: path_provider_ios
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.7"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
path_provider_macos:
dependency: transitive
description:
name: path_provider_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
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.4"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.11.1"
percent_indicator:
dependency: "direct main"
description:
name: percent_indicator
url: "https://pub.dartlang.org"
source: hosted
version: "3.4.0"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "4.4.0"
photo_view:
dependency: transitive
description:
name: photo_view
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.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.2"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
pointycastle:
dependency: transitive
description:
name: pointycastle
url: "https://pub.dartlang.org"
source: hosted
version: "3.4.0"
pool:
dependency: transitive
description:
name: pool
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.0"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.4"
provider:
dependency: "direct main"
description:
name: provider
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.1"
pub_semver:
dependency: transitive
description:
name: pub_semver
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
pubspec_parse:
dependency: transitive
description:
name: pubspec_parse
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1+1"
recase:
dependency: transitive
description:
name: recase
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
requests_inspector:
dependency: "direct main"
description:
name: requests_inspector
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.2+2"
rxdart:
dependency: "direct main"
description:
name: rxdart
url: "https://pub.dartlang.org"
source: hosted
version: "0.27.3"
sensors_plus:
dependency: transitive
description:
name: sensors_plus
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.1"
sensors_plus_platform_interface:
dependency: transitive
description:
name: sensors_plus_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
sensors_plus_web:
dependency: transitive
description:
name: sensors_plus_web
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
shake:
dependency: transitive
description:
name: shake
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
shared_preferences:
dependency: transitive
description:
name: shared_preferences
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.9"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.9"
shared_preferences_ios:
dependency: transitive
description:
name: shared_preferences_ios
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
shared_preferences_macos:
dependency: transitive
description:
name: shared_preferences_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
shared_preferences_platform_interface:
dependency: transitive
description:
name: shared_preferences_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
shared_preferences_web:
dependency: transitive
description:
name: shared_preferences_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
shelf:
dependency: transitive
description:
name: shelf
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
shimmer:
dependency: "direct main"
description:
name: shimmer
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
showcaseview:
dependency: "direct main"
description:
path: "."
ref: HEAD
resolved-ref: "94405aeba5f7f11eb3de9026892e0346c4c78336"
url: "git://github.com/Abdelazeem777/flutter_showcaseview"
source: git
version: "1.1.2"
sign_in_with_apple:
dependency: "direct main"
description:
name: sign_in_with_apple
url: "https://pub.dartlang.org"
source: hosted
version: "3.3.0"
sign_in_with_apple_platform_interface:
dependency: transitive
description:
name: sign_in_with_apple_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
sign_in_with_apple_web:
dependency: transitive
description:
name: sign_in_with_apple_web
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
size_helper:
dependency: "direct main"
description:
name: size_helper
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+1"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
source_gen:
dependency: transitive
description:
name: source_gen
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
source_helper:
dependency: transitive
description:
name: source_helper
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
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.3"
timezone:
dependency: transitive
description:
name: timezone
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.0"
timing:
dependency: transitive
description:
name: timing
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
tuple:
dependency: transitive
description:
name: tuple
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
uuid:
dependency: transitive
description:
name: uuid
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.5"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
video_player:
dependency: "direct main"
description:
name: video_player
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.7"
video_player_platform_interface:
dependency: transitive
description:
name: video_player_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.0"
video_player_web:
dependency: transitive
description:
name: video_player_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
wakelock:
dependency: "direct main"
description:
name: wakelock
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.6"
wakelock_macos:
dependency: transitive
description:
name: wakelock_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.0"
wakelock_platform_interface:
dependency: transitive
description:
name: wakelock_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0"
wakelock_web:
dependency: transitive
description:
name: wakelock_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.0"
wakelock_windows:
dependency: transitive
description:
name: wakelock_windows
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
watcher:
dependency: transitive
description:
name: watcher
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
webview_flutter:
dependency: transitive
description:
name: webview_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.1"
webview_flutter_android:
dependency: transitive
description:
name: webview_flutter_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.1"
webview_flutter_platform_interface:
dependency: transitive
description:
name: webview_flutter_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.2"
webview_flutter_wkwebview:
dependency: transitive
description:
name: webview_flutter_wkwebview
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.1"
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.3.1"
yaml:
dependency: transitive
description:
name: yaml
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
youtube_player_flutter:
dependency: "direct main"
description:
name: youtube_player_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "8.0.0"
sdks:
dart: ">=2.14.0 <3.0.0"
flutter: ">=2.5.0"


</details>

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
- Exception stacktrace

E/flutter (20778): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: type 'CastList<Object?, String>' is not a subtype of type 'String?' of 'other'
E/flutter (20778): #0 ContainsQueryOperator.evaluate (package:amplify_datastore_plugin_interface/src/types/query/query_field_operators.dart)
package:amplify_datastore_plugin_interface/…/query/query_field_operators.dart:1
E/flutter (20778): #1 QueryPredicateOperation.evaluate
package:amplify_datastore_plugin_interface/…/query/query_predicate.dart:59
E/flutter (20778): #2 QuerySnapshot.withSubscriptionEvent
package:amplify_datastore_plugin_interface/…/models/query_snapshot.dart:96
E/flutter (20778): #3 ObserveQueryExecutor.observeQuery.
package:amplify_datastore/types/observe_query_executor.dart:87
E/flutter (20778): #4 _MapStream._handleData (dart:async/stream_pipe.dart:213:31)
E/flutter (20778): #5 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
E/flutter (20778): #6 _rootRunUnary (dart:async/zone.dart:1436:47)
E/flutter (20778): #7 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
E/flutter (20778): #8 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
E/flutter (20778): #9 CastStreamSubscription._onData (dart:_internal/async_cast.dart:85:11)
E/flutter (20778): #10 _rootRunUnary (dart:async/zone.dart:1436:47)
E/flutter (20778): #11 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
E/flutter (20778): #12 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
E/flutter (20778): #13 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
E/flutter (20778): #14 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter (20778): #15 _SyncBroadcastStreamController._sendData (dart:async/broadcast_stream_controller.dart:378:25)
E/flutter (20778): #16 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:244:5)
E/flutter (20778): #17 _AsBroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:475:11)
E/flutter (20778): #18 _rootRunUnary (dart:async/zone.dart:1436:47)
E/flutter (20778): #19 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
E/flutter (20778): #20 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
E/flutter (20778): #21 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
E/flutter (20778): #22 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter (20778): #23 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
E/flutter (20778): #24 _MapStream._handleData (dart:async/stream_pipe.dart:218:10)
E/flutter (20778): #25 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
E/flutter (20778): #26 _rootRunUnary (dart:async/zone.dart:1436:47)
E/flutter (20778): #27 _CustomZone.runUnary (dart:async/zone.dart:1335:19)

@Abdelazeem777
Copy link
Author

After Some playing with the code, I figure out the lint that caused this issue.

 @override
  Stream<Chat> observeUserChatsChanges(String userId) {
    return Amplify.DataStore.observeQuery(
      Chat.classType,
      where: Chat.USERSID.contains(userId), //<== This line is causing the issue
      sortBy: [Chat.LASTMESSAGESENDTIME.descending()],
    )
        .where((snapshot) => snapshot.items.isNotEmpty)
        .map((snapshot) => snapshot.items.first);
  }

So if I removed this line the exception will disappear but still, this is not a solution for this bug.
I still need to filter my chats by userId

@HuiSF HuiSF added the datastore Issues related to the DataStore Category label Dec 22, 2021
@HuiSF
Copy link
Contributor

HuiSF commented Dec 22, 2021

Hi @Abdelazeem777 Thanks for reporting this issue.

What's the data type of the field userId of the Chat model? Do you mind to paste the schema here?

@HuiSF HuiSF added the to-be-reproduced Issues that have not been reproduced yet, but have reproduction steps provided label Dec 22, 2021
@Abdelazeem777
Copy link
Author

@HuiSF
usersId is a list of String (ID).

Screenshot from 2021-12-23 10-17-55

@Jordan-Nelson Jordan-Nelson self-assigned this Dec 28, 2021
@Jordan-Nelson
Copy link
Contributor

My guess is that the .contains() query predicate isn't properly handling lists for observeQuery. I can test this theory out.

Related - If we address issue #840, that would help identify these issues with proper typing.

@Jordan-Nelson Jordan-Nelson added bug Something is not working; the issue has reproducible steps and has been reproduced and removed to-be-reproduced Issues that have not been reproduced yet, but have reproduction steps provided labels Dec 28, 2021
@Jordan-Nelson
Copy link
Contributor

I was able to reproduce this in the DataStore example app with the following code.

// set up subscription
Amplify.DataStore.observeQuery(
  StringListTypeModel.classType,
  where: StringListTypeModel.VALUE.contains('123'),
).listen((QuerySnapshot<StringListTypeModel> snapshot) {
  setState(() {
    print(snapshot.items.length);
  });
});

// add button inside build method
ElevatedButton(
  onPressed: () async {
    await Amplify.DataStore.save(
      StringListTypeModel(value: ['123', 'abc']),
    );
  },
  child: Text('Create String List'),
),

@Jordan-Nelson Jordan-Nelson changed the title Unhandled Exception: type 'CastList<Object?, String>' is not a subtype of type 'String?' of 'other' Query predicates do not properly support lists for observeQuery() Dec 28, 2021
@Jordan-Nelson
Copy link
Contributor

Jordan-Nelson commented Dec 29, 2021

@Abdelazeem777 - I am looking into a fix for this. In the meantime, below is a workaround. If you choose to use this workaround, I would advise testing it thoroughly for your use cases and keeping an eye out for a more permanent fix.

Work Around

Chat.USERSID is of type QueryField. The .contains() method on the QueryField class isn't properly handling lists. This workaround adds a new method, .listContains(), which does properly handle lists. Note: If you try to use .listContains() on a field that isn't a list, it will throw an exception.

  1. Add the following extension to your app, and import it where you would like to use .listContains().
extension ListQueryField on QueryField<dynamic> {
  QueryPredicateOperation listContains(dynamic value) =>
      QueryPredicateOperation(
        this.fieldName,
        ListContainsQueryOperator(value),
      );
}

class ListContainsQueryOperator extends QueryFieldOperator<List<dynamic>> {
  final dynamic value;

  const ListContainsQueryOperator(this.value)
      : super(QueryFieldOperatorType.contains);

  @override
  bool evaluate(List<dynamic>? other) {
    if (other == null) {
      return false;
    }
    return other.contains(value);
  }

  @override
  Map<String, dynamic> serializeAsMap() {
    return serializeAsMapWithOperator(
      QueryFieldOperatorType.contains.toShortString(),
      value,
    );
  }
}
  1. Update the code snippet you had shared to use the new method.
 @override
  Stream<Chat> observeUserChatsChanges(String userId) {
    return Amplify.DataStore.observeQuery(
      Chat.classType,
      where: Chat.USERSID.listContains(userId), // <== UPDATED
      sortBy: [Chat.LASTMESSAGESENDTIME.descending()],
    )
        .where((snapshot) => snapshot.items.isNotEmpty)
        .map((snapshot) => snapshot.items.first);
  }

@offlineprogrammer offlineprogrammer added this to Pending Triage in Issues Triaging via automation Jan 3, 2022
@offlineprogrammer offlineprogrammer moved this from Pending Triage to Bugs in Issues Triaging Jan 3, 2022
@Jordan-Nelson Jordan-Nelson added the pending-release Issues that have been addressed in main but have not been released label Apr 5, 2022
@Jordan-Nelson
Copy link
Contributor

Support for lists has been release in version 0.5.0. The .contains() query predicate now supports Lists.

Issues Triaging automation moved this from Bugs to Closed May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working; the issue has reproducible steps and has been reproduced datastore Issues related to the DataStore Category pending-release Issues that have been addressed in main but have not been released
Projects
No open projects
Development

No branches or pull requests

3 participants