Skip to content

AZ811: A mirrored sync line that can't be mirrored ​

sync app.docs : view mirrored keeps a copy of the table in authz_sync for PowerSync, whose streams key their buckets by a value on the row: each row with every column but the masked ones, and readers, a JSON array of the keys that may read it. Keyed by a type (by folder), those keys would be the folders', a bucket for each folder a user may read, past PowerSync's limit: mirror a line that isn't keyed. Two mirrored tables of one name in two schemas (app.docs, billing.docs) are refused too: a PowerSync client names each table by its own name. Applying also refuses a table with a column of its own named readers, which the mirror keeps the keys in: rename it. And rowstile client powersync reads each mirror's columns from the database: a line the policy mirrors and the database doesn't yet is said: apply or push the policy first.

Reported when the policy is compiled: rowstile check, the editor, rowstile dev.

The mistake ​

authz
app role app_user
type user = app.users
type folder = app.folders
  parent : folder = parent_id
  owner : user = owner_id
  can view = owner or parent.view
type doc = app.docs
  folder : folder = folder_id
  can view = folder.view
sync role sync_engine
sync app.docs : view by folder mirrored
line 11: sync app.docs ... by folder mirrored: a mirror's readers are the keys each row is read by, and keyed by folder they would be folder's keys, a PowerSync bucket for each: mirror the line without by [AZ811]

Fixed ​

authz
app role app_user
type user = app.users
type folder = app.folders
  parent : folder = parent_id
  owner : user = owner_id
  can view = owner or parent.view
type doc = app.docs
  folder : folder = folder_id
  can view = folder.view
sync role sync_engine
sync app.docs : view mirrored