I have a class where each object’s ACL is public-read but write is limited to the user who created it. Let’s say it’s a Post
class in a news feed.
When someone else ‘likes’ this post, I want to store a new Like
object , with a pointer to the liked post
. However, the save fails with a 101
error which I have discovered is due to the liked post
's ACL. If I make the liked post
publicly writable, the save operation is successful.
I can think of a couple of workarounds - storing the object ID instead, or using cloud code - but they are not very graceful and seem like they shouldn’t be necessary.
My questions:
- Is this expected behavior?
- What is the rationale for this behavior? Why wouldn’t a publicly readable object be storable as a pointer in another object?
I wanted to add one observation that may or may not be germane. Elsewhere in my application, I have a Follow
class, which stores a pointer to two users (the user doing the following, and the user being followed). The _User
class has the same restrictions as Post
- public-read and private-write. But here I have no issues saving Follow
objects. Is there something special in this regard about the _User
class, or does it point to some other reason my Post
isn’t saving? I am pretty confident it is due to the post’s ACL, but perhaps there is a class configuration issue in play?
User class has built-in ACL for write operation. User can be read by anyone but only the user can write itself. Users can’t write data to other users.
Ä°f your system working fine with users, I would say your ACLs for Post or Like class are doing more than what you have told. Try creating ACLs again and remove old ones
Thanks @uzaysan, there was as you suggested more to the story, though it was not ACL related.
I was mistakenly updating a property on the linked object (the ‘Post’ in my example), for which the user had no write access. When saving the comment
, the illegal change to the post
was also being saved. It was this cascaded save, not the save of the comment
itself, that was being rejected.