maps icon indicating copy to clipboard operation
maps copied to clipboard

Cannot place contact via map »Failed to place contact: "READONLY"«

Open frlan opened this issue 4 years ago • 13 comments

I wanted to place a contact via the map. I was gettng the dialog asking me for the contact I want to place as well as whether it should be its home or working adress. However, after choosing the flags I'm getting the error:

Failed to place contact: "READONLY"✖

Unfortunately this message might be true, but is not very helpful. I have no idea what the issue is. Running maps: 0.1.6 on Nextcloud 18.0.5.

frlan avatar Jun 06 '20 22:06 frlan

Is the contact in a shared addressbook? Can you edit the contact in the contacts app?

tacruc avatar Jun 07 '20 12:06 tacruc

No -- its not shared and I can edit it.

frlan avatar Jun 07 '20 13:06 frlan

@nextcloud/contacts Does anybody has an Idea, why an addressbook is appears to be read only for maps, but the contact is editable from the contacts app? This is how maps determs if the addressBook is read only:

private function addressBookIsReadOnly($bookid) {
        $userBooks = $this->cdBackend->getAddressBooksForUser('principals/users/'.$this->userId);
        foreach ($userBooks as $book) {
            if ($book['id'] === $bookid) {
                return (isset($book['{http://owncloud.org/ns}read-only']) and $book['{http://owncloud.org/ns}read-only']);
            }
        }
        return true;
    }

tacruc avatar Jun 08 '20 14:06 tacruc

@frlan could you generate a system report https://your.instance/settings/admin/support and upload or email it to me. I'm not shure if it is there allready for NC 18, but there might be a menu point report issue.

tacruc avatar Jun 08 '20 14:06 tacruc

no idea! :/ @georgehrke

skjnldsv avatar Jun 09 '20 09:06 skjnldsv

The readonly attribute is set here: https://github.com/nextcloud/server/blob/de35da37ceffe7468c1e30d6067f99b881aff2b5/apps/dav/lib/CardDAV/CardDavBackend.php#L224

It is never set for addressbooks you own though: https://github.com/nextcloud/server/blob/de35da37ceffe7468c1e30d6067f99b881aff2b5/apps/dav/lib/CardDAV/CardDavBackend.php#L159

There is also a check that shared addressbooks don't override your own, so that can't be the reason: https://github.com/nextcloud/server/blob/de35da37ceffe7468c1e30d6067f99b881aff2b5/apps/dav/lib/CardDAV/CardDavBackend.php#L194

georgehrke avatar Jun 09 '20 10:06 georgehrke

The error is only Raised if the addressBookIsReadOnly returns true: https://github.com/nextcloud/maps/blob/d1d440b3f6072b897cc6b5de43fe55f059750a4c/lib/Controller/ContactsController.php#L174.

This never happens if the addressbook is your own.

So I guess we need some more information from @frlan. A compled filled out template https://github.com/nextcloud/server/blob/master/.github/ISSUE_TEMPLATE/Bug_report.md could be helpfull.

tacruc avatar Jun 09 '20 10:06 tacruc

@tacruc The only possible source of error i could spot in your code is this line:

            if ($book['id'] === $bookid) {

We do not explicitly typecast it in the backend, so depending on the type of $bookid, this condition may never be true. Better explicitly typecast $book['id'] to the same type as $bookid

https://github.com/nextcloud/server/blob/862e3250fffa78c0d0a51f20034369abf99fc468/apps/dav/lib/CardDAV/CardDavBackend.php#L160

georgehrke avatar Jun 09 '20 11:06 georgehrke

@georgehrke thanks, I will have a look into it. One possible issue I see is, that $bookid is not fixed in type either. Would make $book['id'] == $bookid make sense than?

tacruc avatar Jun 09 '20 11:06 tacruc

I'm not sure if my diagnostics will be particularly useful here, but I'm experiencing the exact same issue @frlan described, on Nextcloud 19.0.4 and Maps 0.1.6. The contact is in my own address book, and I definitely have write access to it. Happy to provide any logs or diagnostic dumps that are required!

apetresc avatar Oct 28 '20 01:10 apetresc

Could it be caused by the index contact_uid stripped out in https://github.com/nextcloud/maps/commit/1a76b935a2459be64abfbdb86072129d12e45856?

gianlucagiacometti avatar May 14 '21 16:05 gianlucagiacometti

The issue still exists with Nextcloud 21.0.4 and maps 0.1.9

It's a duplicate of #222

Also it doesn't only affect contacts when placed via the map. Contacts that have adresses added via the Contacts app don't appear on the map either.

conrad-mobilitas avatar Aug 09 '21 12:08 conrad-mobilitas

Also seeing this in v23

meichthys avatar Jun 10 '22 20:06 meichthys