The data source is either read-only or has no primary key, so the function Patch can’t write to it. - #ARCHIVED#

This content has been archived. It may no longer be relevant.  

This is a design time error for Power Apps canvas apps:

I encountered this by coincidence and was able to find the cause.

I had implemented an audit log using SharePoint Online. See the following blog post for more information: Create an audit log using a SharePoint Online list

So on a SharePoint Online list, I configured a custom permission level making sure users could only read and add items. While working on the business solution where a canvas app wrote items in the SharePoint Online list (audit log), I had full control permissions on that list. At a certain moment, a colleague wanted to make changes to the canvas app (he was co-owner), so he opened the canvas app in the canvas app designer and then the error message was shown.

My first guess was that it was security related and that was indeed the case. When he opened the canvas app designer, he was a normal user for that SharePoint Online list. The canvas app designer checks available permissions on a SharePoint Online list when a patch function is used on it. Because of the custom permission level where a user could only add items, and because the function Patch can also be used to update items, an error was thrown.

In run mode, the canvas app worked just fine. A user was able to add items in the SharePoint Online list (audit log). The design time error thus does not result in a runtime error.