After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 694188 - sqlite backend: non-standard "not found" error
sqlite backend: non-standard "not found" error
Status: RESOLVED FIXED
Product: evolution-data-server
Classification: Platform
Component: Contacts
3.8.x (obsolete)
Other Linux
: Normal normal
: ---
Assigned To: evolution-addressbook-maintainers
Evolution QA team
Depends on:
Blocks:
 
 
Reported: 2013-02-19 16:45 UTC by Patrick Ohly
Modified: 2013-09-14 16:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
return known error code (1.41 KB, patch)
2013-02-19 16:48 UTC, Patrick Ohly
none Details | Review

Description Patrick Ohly 2013-02-19 16:45:06 UTC
SyncEvolution has a test which checks the result of removing a contact which doesn't exist. The expectation is that e_book_client_remove_contact_by_uid_sync() returns E_BOOK_CLIENT_ERROR/E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND.

This started to fail with the introduction of the sqlite backend.
Comment 1 Patrick Ohly 2013-02-19 16:48:09 UTC
Created attachment 236789 [details] [review]
return known error code
Comment 2 Tristan Van Berkom 2013-02-21 11:45:03 UTC
Currently EBookBackendSQLiteDB has it's own error codes, and
returns an explicit error E_BOOK_SDB_ERROR_CONTACT_NOT_FOUND.

The EBookBackendFile makes sure to translate this to the correct
EDataBookStatus

And the test case test-client-remove-contact.c ensures that
E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND is reported after
a contact is removed.
Comment 3 Patrick Ohly 2013-02-21 15:04:24 UTC
(In reply to comment #2)
> Currently EBookBackendSQLiteDB has it's own error codes, and
> returns an explicit error E_BOOK_SDB_ERROR_CONTACT_NOT_FOUND.
> 
> The EBookBackendFile makes sure to translate this to the correct
> EDataBookStatus

That didn't work for me. I don't know how the mapping works, so I can't come up with a different patch.

> And the test case test-client-remove-contact.c ensures that
> E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND is reported after
> a contact is removed.

There's a misunderstanding. The test checks that get_contact returns E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND. That works.

What also needs to work is that remove_contact_by_uid, too, returns E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND when the uid is not found. That doesn't work. Instead the client gets the incomprehensible, backend internal error code.
Comment 4 Patrick Ohly 2013-02-21 15:16:07 UTC
Change the test as follows and it'll fail:

diff --git a/tests/libebook/client/test-client-remove-contact.c b/tests/libebook/client/test-client-remove-contact.c
index bb314aa..bdc88dd 100644
--- a/tests/libebook/client/test-client-remove-contact.c
+++ b/tests/libebook/client/test-client-remove-contact.c
@@ -21,6 +21,14 @@ check_removed_contact (EBookClient *book_client,
 			 error->message, g_quark_to_string (error->domain), error->code);
 	else
 		g_clear_error (&error);
+
+	if (e_book_client_remove_contact_by_uid_sync (book_client, uid, NULL, &error))
+		g_error ("succeeded to remove removed contact again");
+	else if (!g_error_matches (error, E_BOOK_CLIENT_ERROR, E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND))
+		g_error ("Wrong error in remove contact sync on removed contact: %s (domain: %s, code: %d)",
+			 error->message, g_quark_to_string (error->domain), error->code);
+	else
+		g_clear_error (&error);
 }
 
 static void


** (/work/gnome/checkout/evolution-data-server/tests/libebook/client/.libs/lt-test-client-remove-contact:9386): ERROR **: Wrong error in remove contact sync on removed contact: GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._e_2dbook_2dbackend_2dsqlitedb_2derror_2dquark.Code1: Cannot remove contacts: Contact 'pas-id-512639F200000000' not found (domain: e-book-backend-sqlitedb-error-quark, code: 1)
Comment 5 Tristan Van Berkom 2013-02-22 09:47:52 UTC
Fixed in master with these commits:

commit 4cbd466c71012968d998b06c1a13c959340d18c2
Author: Tristan Van Berkom <tristanvb@openismus.com>
Date:   Fri Feb 22 18:33:07 2013 +0900

    EBookBackendFile: Report the correct error from remove_contacts()
    
    If the EBookBackenSqliteDB reports CONTACT_NOT_FOUND, then use
    E_DATA_BOOK_STATUS_CONTACT_NOT_FOUND, this causes test-client-remove-contact
    to pass again.
    
    See bug: https://bugzilla.gnome.org/show_bug.cgi?id=694188

commit 97a725e8546c2f5e0566312bc81d1c518bcd9eec
Author: Tristan Van Berkom <tristanvb@openismus.com>
Date:   Fri Feb 22 18:31:59 2013 +0900

    test-client-remove-contact.c: Enhanced test case
    
    Check that removing a removed contact reports the correct error code
    
    See bug: https://bugzilla.gnome.org/show_bug.cgi?id=694188