amplify-flutter icon indicating copy to clipboard operation
amplify-flutter copied to clipboard

More granular query access in Auth rule leads to "invalid string supplied: LIST"

Open ruossn opened this issue 2 years ago • 3 comments

Description

If we add an read auth rule operation (listen, list, ...) instead of general "read" we get an "java.lang.Exception: stringToModelOperation - invalid string supplied: LIST" Exception while adding the Datastore Plugin. If we replace it with "read" we can add the Datastore plugin.

The complete error in the Terminal:

E/DartMessenger(30599): Uncaught exception in binary message listener E/DartMessenger(30599): java.lang.Exception: stringToModelOperation - invalid string supplied: LIST E/DartMessenger(30599): at com.amazonaws.amplify.amplify_datastore.types.model.FlutterAuthRule.stringToModelOperation(FlutterAuthRule.kt:40) E/DartMessenger(30599): at com.amazonaws.amplify.amplify_datastore.types.model.FlutterAuthRule.(FlutterAuthRule.kt:20) E/DartMessenger(30599): at com.amazonaws.amplify.amplify_datastore.types.model.FlutterModelSchema.(FlutterModelSchema.kt:16) E/DartMessenger(30599): at com.amazonaws.amplify.amplify_datastore.AmplifyDataStorePlugin.registerSchemas(AmplifyDataStorePlugin.kt:728) E/DartMessenger(30599): at com.amazonaws.amplify.amplify_datastore.AmplifyDataStorePlugin.onConfigureDataStore(AmplifyDataStorePlugin.kt:222) E/DartMessenger(30599): at com.amazonaws.amplify.amplify_datastore.AmplifyDataStorePlugin.onMethodCall(AmplifyDataStorePlugin.kt:194) E/DartMessenger(30599): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258) E/DartMessenger(30599): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) E/DartMessenger(30599): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322) E/DartMessenger(30599): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/DartMessenger(30599): at android.os.Handler.handleCallback(Handler.java:942) E/DartMessenger(30599): at android.os.Handler.dispatchMessage(Handler.java:99) E/DartMessenger(30599): at android.os.Looper.loopOnce(Looper.java:201) E/DartMessenger(30599): at android.os.Looper.loop(Looper.java:288) E/DartMessenger(30599): at android.app.ActivityThread.main(ActivityThread.java:7898) E/DartMessenger(30599): at java.lang.reflect.Method.invoke(Native Method) E/DartMessenger(30599): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) E/DartMessenger(30599): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) I/flutter (30599): Amplify plugin was not added

Categories

  • [ ] Analytics
  • [ ] API (REST)
  • [ ] API (GraphQL)
  • [ ] Auth
  • [ ] Authenticator
  • [X] DataStore
  • [ ] Notifications (Push)
  • [ ] Storage

Steps to Reproduce

No response

Screenshots

No response

Platforms

  • [ ] iOS
  • [X] Android
  • [ ] Web
  • [ ] macOS
  • [ ] Windows
  • [ ] Linux

Flutter Version

3.10.5

Amplify Flutter Version

1.2.0-supports-only-mobile+1

Deployment Method

Amplify CLI

Schema

type Partner
@model(
    queries: { get: "getPartner", list: "listPartner" },
    subscriptions: null)
@auth(rules: [
    { allow: public, provider: apiKey, operations: [read] },
    { allow: private, provider: iam, operations: [list] }
])
{
    publicId: ID! @primaryKey
...
}

...

ruossn avatar Jul 18 '23 10:07 ruossn

There is a known gap leveraging granular GraphQL operation controls in both amplify-swift and amplify-android. PRs were open for both libraries to use granular control.

https://github.com/aws-amplify/amplify-android/pull/2265 https://github.com/aws-amplify/amplify-swift/pull/2720

We need to get them merged first then can test support using granular control in Amplify Flutter DataStore.

HuiSF avatar Jul 18 '23 19:07 HuiSF

Thanks for your fast response. Maybe that should be documented or is it documented and i was just not able to find it?

ruossn avatar Jul 19 '23 05:07 ruossn

@ruossn - Apologies for the delayed response. I do not believe this is documented as it is not intended behavior and is considered a bug.

For those interested in this, support is pending work in Amplify Swift and we're tracking efforts for that here

Jordan-Nelson avatar May 01 '24 17:05 Jordan-Nelson