cubicweb #529890 bad ERQLExpression raises non-explicit traceback [open]

We had an error on a startup page for unauthenticated users. The request 'Any W WHERE W is WorkCase' raised a traceback difficult to understand.

The error is coming from a bad ERQLExpression (from iliane cube l.86): ERQLExpression('U other_agency_in_charge K, K applied_to X, K is CodeKeyword')

It's maybe possible to help the diagnostic by triggering this error in a better way. Here is the traceback:

Traceback (most recent call last)
 File "/home/juj/src/fcubicweb/logilab/common/", line 1182, in _proceed
   testfunc(*args, **kwargs)
 File "/tmp/iliane/test/", line 261, in test_workcase_business_read_permissions_status_10_11
   wcase = self._check_workcase_policy(status)
 File "/tmp/iliane/test/", line 188, in _check_workcase_policy
   self.assertCanSelectAllWorkCases(wcase, [chef, taskgroup_member, somebody])
 File "/tmp/iliane/test/", line 103, in assertCanSelectAllWorkCases
   self.execute('Any W WHERE W is WorkCase')
 File "/home/juj/src/fcubicweb/logilab/common/", line 168, in not_covered
   return func(*args, **kwargs)
 File "/home/juj/src/fcubicweb/cubicweb/devtools/", line 139, in execute
   return self.env.execute(*args, **kwargs)
 File "/home/juj/src/fcubicweb/cubicweb/devtools/", line 160, in execute
   return self.cnx.cursor(req).execute(unicode(rql), args, eidkey)
 File "/home/juj/src/fcubicweb/cubicweb/", line 668, in execute
   parameters, eid_key, build_descr)
 File "/home/juj/src/fcubicweb/cubicweb/server/", line 611, in execute
 File "/home/juj/src/fcubicweb/cubicweb/devtools/", line 268, in new_execute
   rset = base_execute(*args, **kwargs)
 File "/home/juj/src/fcubicweb/cubicweb/server/", line 647, in execute
 File "/home/juj/src/fcubicweb/cubicweb/server/", line 36, in build_plan
   for step in build_plan(plan, plan.rqlst):
 File "/home/juj/src/fcubicweb/cubicweb/server/", line 45, in build_select_plan
 File "/home/juj/src/fcubicweb/cubicweb/server/", line 196, in preprocess
   self._insert_security(union, noinvariant)
 File "/home/juj/src/fcubicweb/cubicweb/server/", line 270, in _insert_security
   rewrite(myrqlst, lcheckdef, lchecksolutions, self.args)
 File "/home/juj/src/fcubicweb/cubicweb/", line 154, in rewrite
 File "/home/juj/src/fcubicweb/cubicweb/", line 199, in insert_snippets
   new = self.insert_snippet(varmap, rqlexpr.snippet_rqlst, parent)
 File "/home/juj/src/fcubicweb/cubicweb/", line 221, in insert_snippet
   return self._insert_snippet(varmap, parent, new)
 File "/home/juj/src/fcubicweb/cubicweb/", line 248, in _insert_snippet
   parent.parent.replace(or_, or_.children[0])
 File "/home/juj/src/fcubicweb/rql/", line 147, in replace
   i = self.children.index(old_child)
ValueError: list.index(x): x not in list

To reproduce the problem:

hg clone ~juj/src/fcubicweb/cubes/iliane -r 579

cd iliane

pytest test/ 10

done in<not specified>
load left0.300
closed by<not specified>