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 764078 - Improve error messages
Improve error messages
Status: RESOLVED FIXED
Product: grilo
Classification: Other
Component: lua
git master
Other Linux
: Normal normal
: ---
Assigned To: Victor Toso
grilo-maint
Depends on:
Blocks:
 
 
Reported: 2016-03-23 14:25 UTC by Bastien Nocera
Modified: 2016-05-26 11:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
quick fix (832 bytes, patch)
2016-03-23 23:07 UTC, Victor Toso
reviewed Details | Review
lua-factory: include error message for broken source (4.54 KB, patch)
2016-05-19 20:47 UTC, Victor Toso
none Details | Review
lua-factory: fix syntax-check for lua-sources (2.55 KB, patch)
2016-05-19 20:47 UTC, Victor Toso
committed Details | Review
metrolyrics: lower failure from warning to debug (1.55 KB, patch)
2016-05-19 20:53 UTC, Victor Toso
committed Details | Review
lua-factory: include error message for broken source (4.50 KB, patch)
2016-05-21 06:54 UTC, Victor Toso
committed Details | Review
lua-factory: avoid leak of GrlNetWc on failure (1.02 KB, patch)
2016-05-21 06:54 UTC, Victor Toso
committed Details | Review
lua-factory: support to cancel operation (10.36 KB, patch)
2016-05-25 20:41 UTC, Victor Toso
rejected Details | Review

Description Bastien Nocera 2016-03-23 14:25:04 UTC
Loading the grl-guardian-eyewitness source throws:

(grilo-test-ui-0.3:30905): Grilo-WARNING **: [lua-library-operations] grl-lua-library-operations.c:671: operation-id: 1 is on FINALIZED state and cannot be changed

(grilo-test-ui-0.3:30905): Grilo-WARNING **: [lua-library] grl-lua-library.c:532: calling source callback function fail: /home/hadess/Projects/gnome-install/share/grilo-plugins/grl-lua-factory/grl-guardian-eyewitness.lua:90: Source is broken as callback was called after the operation has been finalized

(grilo-test-ui-0.3:30905): Grilo-WARNING **: [lua-library-operations] grl-lua-library-operations.c:671: operation-id: 2 is on FINALIZED state and cannot be changed

(grilo-test-ui-0.3:30905): Grilo-WARNING **: [lua-library] grl-lua-library.c:532: calling source callback function fail: /home/hadess/Projects/gnome-install/share/grilo-plugins/grl-lua-factory/grl-guardian-eyewitness.lua:90: Source is broken as callback was called after the operation has been finalized

There are probably more errors than really necessary, and it doesn't explain how to fix it. Did it call grl.callback when it already received all the necessary items? I think that this error is incorrect though.
Comment 1 Victor Toso 2016-03-23 23:05:37 UTC
Yes, it is too verbose, sorry about that. I would prefer to keep the verbosity of the warnings/debug for a little in order to see a problem easily.

Regarding the error, it seems correct. You can grl.debug(count) to see that it calls grl.callback() several times till count goes to 0 but after that it calls again with count == -1.

Following patch fixes it.
Comment 2 Victor Toso 2016-03-23 23:07:28 UTC
Created attachment 324634 [details] [review]
quick fix
Comment 3 Bastien Nocera 2016-03-24 11:49:54 UTC
Review of attachment 324634 [details] [review]:

OK. That means it's likely a bug in the backend that returns items than requested.

Still, the error message should mention (as it used to) that the source has already been called with "0" items left, rather than it being in a finalized state.

I'll investigate the eyewitness bug itself now.
Comment 4 Victor Toso 2016-03-24 12:18:31 UTC
(In reply to Bastien Nocera from comment #3)
> Review of attachment 324634 [details] [review] [review]:
> 
> OK. That means it's likely a bug in the backend that returns items than
> requested.
> 
> Still, the error message should mention (as it used to) that the source has
> already been called with "0" items left, rather than it being in a finalized
> state.

Sure, I'll try to improve the messages soon.
Comment 5 Bastien Nocera 2016-03-24 13:03:35 UTC
FWIW, the handling of count/skip/page was completely wrong in the source, I fixed that in grilo-lua-sources.

Leaving this open for the better error message.
Comment 6 Bastien Nocera 2016-05-19 18:34:40 UTC
This is still a problem.

When there's a syntax error, I would get something like:
(test_games:30940): Grilo-WARNING **: [lua-library-operations] grl-lua-library-operations.c:538: Source 'grl-thegamesdb' is broken, as the finishing callback was not called for resolve operation

Instead of an error about the syntax error.
Comment 7 Victor Toso 2016-05-19 20:47:36 UTC
Created attachment 328231 [details] [review]
lua-factory: include error message for broken source

On grl_lua_operations_get_current_op failure, the lua-library api now
issues a lua_error which points to file and line number where the
error happened.

If we can't retrieve the current operation it means that
grl.callback() was called and the grilo operation has been finalized.
Comment 8 Victor Toso 2016-05-19 20:47:42 UTC
Created attachment 328232 [details] [review]
lua-factory: fix syntax-check for lua-sources
Comment 9 Victor Toso 2016-05-19 20:53:50 UTC
Created attachment 328233 [details] [review]
metrolyrics: lower failure from warning to debug
Comment 10 Bastien Nocera 2016-05-20 20:04:58 UTC
Review of attachment 328231 [details] [review]:

> On grl_lua_operations_get_current_op failure, the lua-library api now

When grl_lua_operations_get_current_op() fails...

issues a lua_error which points to file and line number where the
error happened.
 
If we can't retrieve the current operation it means that
grl.callback() was called and the grilo operation has been finalized.

::: src/lua-factory/grl-lua-library-operations.c
@@ +668,3 @@
      * watchdog to free its data. Only a broken source would request
      * OperationSpec on FINALIZED State */
+    GRL_DEBUG ("The grilo operation has ended on grl.callback call. "

The grilo operation ended when grl.callback() was called.

::: src/lua-factory/grl-lua-library.c
@@ +747,3 @@
+  if (os == NULL) {
+    luaL_error (L, "grl.get_options failed: Can't retrieve current operation. "
+                "Source is broken as grl.callback has been called but source "

Line up that line with the quotes on the line above.

And everywhere else, I'd rather have grl.callback() than a bare one.

@@ -1445,3 @@
   GRL_DEBUG ("grl.unzip() -> '%s'", url);
 
-  wc = net_wc_new_with_options (L, 3);

That's a separate fix, isn't it?
Comment 11 Bastien Nocera 2016-05-20 20:05:51 UTC
Review of attachment 328232 [details] [review]:

Looks good.
Comment 12 Bastien Nocera 2016-05-20 20:06:42 UTC
Review of attachment 328233 [details] [review]:

Yes.
Comment 13 Victor Toso 2016-05-21 06:54:52 UTC
Created attachment 328301 [details] [review]
lua-factory: include error message for broken source

When grl_lua_operations_get_current_op() fails issues a lua_error
which points to file and line number where the error happened.

If we can't retrieve the current operation it means that
grl.callback() was called and the grilo operation has been finalized.
Comment 14 Victor Toso 2016-05-21 06:54:58 UTC
Created attachment 328302 [details] [review]
lua-factory: avoid leak of GrlNetWc on failure
Comment 15 Victor Toso 2016-05-25 20:41:45 UTC
Created attachment 328529 [details] [review]
lua-factory: support to cancel operation

Grilo has optional method to cancel operations which Lua-Factory had
not implemented so far, till now.

For each operation we create a GCancellabe that should be used in
async functions in Lua-Library such as grl.fetch and grl.unzip.

The grl_lua_operations_cancel_operation(), will cancel the operation,
remove the OperationSpec from its internals and free the related data.

https://bugzilla.gnome.org/show_bug.cgi?id=764077
Comment 16 Victor Toso 2016-05-25 20:43:43 UTC
Review of attachment 328529 [details] [review]:

wrong bug.
Comment 17 Bastien Nocera 2016-05-26 10:26:39 UTC
Review of attachment 328301 [details] [review]:

Looks good.
Comment 18 Bastien Nocera 2016-05-26 10:27:03 UTC
Review of attachment 328302 [details] [review]:

Sure.
Comment 19 Victor Toso 2016-05-26 11:20:15 UTC
Attachment 328232 [details] pushed as 3c0e9a0 - lua-factory: fix syntax-check for lua-sources
Attachment 328233 [details] pushed as 51a0e32 - metrolyrics: lower failure from warning to debug
Attachment 328301 [details] pushed as 8f66902 - lua-factory: include error message for broken source
Attachment 328302 [details] pushed as b53c902 - lua-factory: avoid leak of GrlNetWc on failure