Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access scope using Kind Name on Google Cloud / Android Mobile Backend Starter

Documentation for the Google Cloud MBS states that access to stored Entities can be controlled via prefixing the KindName of that entity with strings "[public]" or "[private]" (or nothing).

https://cloud.google.com/developers/articles/mobile-backend-starter-api-reference#acfce

However attempting insertion of CloudEntities into the Datastore using KindNames that start with [public] or [private] causes an exception/error, specifically that the KindName is invalid.

This is the case both for the Backend running in Open and in Secured mode (using Google login credentials to derive the _owner field)

e.g. here I use KindName "[public]TestDB" which fails, whereas "TestDB" would not throw any exception.

04-22 19:57:54.132: E/AndroidRuntime(4690): Process: com.example.package, PID: 4690

04-22 19:57:54.132: E/AndroidRuntime(4690): java.lang.IllegalArgumentException: Illegal kind name: [public]TestDB

04-22 19:57:54.132: E/AndroidRuntime(4690): at com.google.cloud.backend.core.CloudEntity.(CloudEntity.java:86)

04-22 19:57:54.132: E/AndroidRuntime(4690): at com.example.package.CloudUtil.convertUpdatesToCEList(CloudUtil.java:252)

04-22 19:57:54.132: E/AndroidRuntime(4690): at com.example.package.CloudUtil.checkSync(CloudUtil.java:199)

The relevant section of code editted/compressed for brevity is:

    CloudBackendMessaging cbm=_cloudfrag.getCloudBackend();

    List<CloudEntity> entries=new ArrayList<CloudEntity>();

    while (...) {
      CloudEntity ce=new CloudEntity(_CLOUD_DB_KIND);
      ce.put("fieldname", devID);
      entries.add(ce);
    }


             _countActivity.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                      cbm.updateAll(entries, handler);
                }
            });

Where handler is the callback and _cloudfrag is the CloudBackendFragment from the sample code.

I get the same effect using both inserts and updates, for single or multiple i.e. lists of entities at a time.

I can only think I'm misunderstanding the documentation - but it seems fairly explicit that KindNames can begin with [public] [private] etc?

like image 649
jcollomosse Avatar asked Nov 10 '22 09:11

jcollomosse


1 Answers

Judging by the bug reports on github from others experiencing the same issue, this is a bug in Google's MBS library.

Unfortunately the response to this has been silence for months until tonight the devs posted a single commit updating the readme file to indicate this library is no longer supported and is not an official google product (despite it being pushed as a starter kit with every cloud project started from the console!).

https://github.com/GoogleCloudPlatform/solutions-mobile-backend-starter-android-client/pull/16

Looking at the source I think this access modifier feature was never actually implemented despite documentation to the contrary.

like image 121
jcollomosse Avatar answered Nov 15 '22 00:11

jcollomosse