Details
-
Bug
-
Resolution: Fixed
-
Critical
-
7.1.0
-
7.1.0-2093
-
Untriaged
-
1
-
Yes
Description
fresh install
kv,n1ql,index
bucket named default
create primary index on default
create a user - we call him jackDoe
GRANT query_execute_global_external_functions to jackDoe
create a function
curl -s -k -X POST http://172.23.104.110:8093/evaluator/v1/libraries/n1ql -u Administrator:password -H 'content-type: application/json' -d 'function rbac_default() { var query = SELECT d.* FROM default d ORDER BY META(d).id LIMIT 1; var acc = []; for (const row of query)
CREATE OR REPLACE FUNCTION rbac_default() LANGUAGE JAVASCRIPT AS "rbac_default" AT "n1ql"
now attempt to run the above function as jackDoe (we have tried via cbq and via rest
[root@localhost bin]# ./cbq -u jackDoe -p password1
Connected to : http://localhost:8091/. Type Ctrl-D or \QUIT to exit.
Path to history file for the shell : /root/.cbq_history
cbq> EXECUTE FUNCTION rbac_default();
{
"requestID": "e7d230db-ec32-4d71-b36f-53bf10b19316",
"signature": null,
"results": [
],
"errors": [
{
"code": 10109,
"msg": "Error executing function rbac_default (n1ql:rbac_default): Evaluator error Exceptions from JS code : run rbac_default failed:\nException: Error: Server returned nothing (no headers, no data)\nLocation: functions/n1ql.js:1 \nCode: function rbac_default() { var query = N1QL('SELECT d.* FROM default d ORDER BY META(d).id LIMIT 1;', {}, true); var acc = []; for (const row of query) { acc.push(row); }
return acc;}\nError\n at rbac_default (functions/n1ql.js:1:50)\n - cause: Evaluator error Exceptions from JS code : run rbac_default failed:\nException: Error: Server returned nothing (no headers, no data)\nLocation: functions/n1ql.js:1 \nCode: function rbac_default() { var query = N1QL('SELECT d.* FROM default d ORDER BY META(d).id LIMIT 1;', {}, true); var acc = []; for (const row of query)
{ acc.push(row); } return acc;}\nError\n at rbac_default (functions/n1ql.js:1:50)\n"
}
],
"status": "errors",
"metrics":
}
if you check the query logs you will observe there is a panic as well
2022/01/20 11:22:09 http: panic serving 127.0.0.1:45306: runtime error: invalid memory address or nil pointer dereference
panic(0x22fd080, 0x37e1970)
/home/couchbase/.cbdepscache/exploded/x86_64/go-1.16.6/go/src/runtime/panic.go:971 +0x499
Am currently looking into when it first regressed, so far all the way up to build 2000 it observes the panic and above error message, will update this section of the bug when I find when it last succeeded