Setting permissions for MetaBot does not work

When trying to allow MetaBot access rights to our tables (I assume that is needed in order to make the MetaBot work at all and to provide data into Slack), the system fails to do so.
I can activate the fields and they are turning green on the “permissions” screen. I can also hit the “save” button and can confirm that I want to do the changes. But when I press the “Yes” button, nothing happens. The settings are never saved and in the log file I can see an error (see down below).

We’re running version 0.33.0 against a PostgreSQL database.

What I try to get working is to have the MetaBot send question results into Slack. It doesn’t work for us at the moment so my assumption was that the permissions have to be granted to allow MetaBot to access the required tables.
If this is not needed, the described behaviour of the permissions page still seems to be a bug.

[b4307b90-15da-450a-ba6a-e8ca50057fa3] 2019-09-06T16:35:40+02:00 DEBUG metabase.middleware.log GET /api/user/current 200 27.6 ms (3 DB calls) Jetty threads: 4/50 (4 idle, 0 queued) (69 total active threads) Queries in flight: 0
[b4307b90-15da-450a-ba6a-e8ca50057fa3] 2019-09-06T16:35:40+02:00 DEBUG metabase.middleware.log GET /api/session/properties 200 10.5 ms (1 DB calls) Jetty threads: 3/50 (5 idle, 0 queued) (69 total active threads) Queries in flight: 0
[b4307b90-15da-450a-ba6a-e8ca50057fa3] 2019-09-06T16:35:40+02:00 DEBUG metabase.middleware.log GET /api/database 200 29.4 ms (3 DB calls) Jetty threads: 4/50 (4 idle, 0 queued) (69 total active threads) Queries in flight: 0
[b4307b90-15da-450a-ba6a-e8ca50057fa3] 2019-09-06T16:35:40+02:00 DEBUG metabase.middleware.log GET /api/setting 200 1.6 ms (0 DB calls) Jetty threads: 4/50 (4 idle, 0 queued) (69 total active threads) Queries in flight: 0
[b4307b90-15da-450a-ba6a-e8ca50057fa3] 2019-09-06T16:35:51+02:00 DEBUG metabase.middleware.log GET /api/permissions/graph 200 63.7 ms (4 DB calls) Jetty threads: 3/50 (5 idle, 0 queued) (71 total active threads) Queries in flight: 0
[b4307b90-15da-450a-ba6a-e8ca50057fa3] 2019-09-06T16:37:06+02:00 ERROR metabase.models.permissions Failed to grant permissions
[b4307b90-15da-450a-ba6a-e8ca50057fa3] 2019-09-06T16:37:06+02:00 ERROR metabase.models.permissions Failed to grant permissions
[b4307b90-15da-450a-ba6a-e8ca50057fa3] 2019-09-06T16:37:08+02:00 ERROR metabase.middleware.log PUT /api/permissions/graph 500 1.0 s (8 DB calls)
{:message
“ERROR: null value in column “before” violates not-null constraint\n Detail: Failing row contains (7, null, {“3”:{“2”:{“native”:“write”,“schemas”:“all”}}}, 1, 2019-09-06 14:37:06.613, null).”,
:type org.postgresql.util.PSQLException,
:stacktrace
(“org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440)”
“org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183)”
“org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308)”
“org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)”
“org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)”
“org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143)”
“org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:120)”
“com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:462)”
“clojure.java.jdbc$db_do_execute_prepared_return_keys$exec_and_return_keys__15486.invoke(jdbc.clj:961)”
“clojure.java.jdbc$db_do_execute_prepared_return_keys.invokeStatic(jdbc.clj:989)”
“clojure.java.jdbc$db_do_execute_prepared_return_keys.invoke(jdbc.clj:945)”
“clojure.java.jdbc$db_do_prepared_return_keys.invokeStatic(jdbc.clj:1020)”
“clojure.java.jdbc$db_do_prepared_return_keys.invoke(jdbc.clj:997)”
“toucan.db$simple_insert_many_BANG_$iter__18379__18383$fn__18384$fn__18385.invoke(db.clj:551)”
“toucan.db$simple_insert_many_BANG_$iter__18379__18383$fn__18384.invoke(db.clj:549)”
“clojure.lang.LazySeq.sval(LazySeq.java:42)”
“clojure.lang.LazySeq.seq(LazySeq.java:51)”
“clojure.lang.RT.seq(RT.java:535)”
“clojure.core$seq__5402.invokeStatic(core.clj:137)”
“clojure.core$dorun.invokeStatic(core.clj:3133)”
“clojure.core$doall.invokeStatic(core.clj:3148)”
“clojure.core$doall.invoke(core.clj:3148)”
“toucan.db$simple_insert_many_BANG_.invokeStatic(db.clj:548)”
“toucan.db$simple_insert_many_BANG_.invoke(db.clj:534)”
“toucan.db$simple_insert_BANG_.invokeStatic(db.clj:581)”
“toucan.db$simple_insert_BANG_.invoke(db.clj:570)”
“toucan.db$insert_BANG_.invokeStatic(db.clj:598)”
“toucan.db$insert_BANG_.invoke(db.clj:585)”
“toucan.db$insert_BANG_.invokeStatic(db.clj:601)”
“toucan.db$insert_BANG_.doInvoke(db.clj:585)”
“clojure.lang.RestFn.invoke(RestFn.java:731)”
“–> models.permissions$save_perms_revision_BANG_.invokeStatic(permissions.clj:676)”
“models.permissions$save_perms_revision_BANG_.invoke(permissions.clj:671)”
“models.permissions$fn__27336$update_graph_BANG___27345$fn__27346$fn__27350.invoke(permissions.clj:707)”
“models.permissions$fn__27336$update_graph_BANG___27345$fn__27346.invoke(permissions.clj:704)”
“models.permissions$fn__27336$update_graph_BANG___27345.invoke(permissions.clj:692)”
“api.permissions$fn__61045.invokeStatic(permissions.clj:80)”
“api.permissions$fn__61045.invoke(permissions.clj:68)”
“middleware.auth$enforce_authentication$fn__63982.invoke(auth.clj:14)”
“routes$fn__65132$fn__65133.doInvoke(routes.clj:56)”
“middleware.exceptions$catch_uncaught_exceptions$fn__64081.invoke(exceptions.clj:104)”
“middleware.exceptions$catch_api_exceptions$fn__64078.invoke(exceptions.clj:92)”
“middleware.log$log_api_call$fn__65506$fn__65507.invoke(log.clj:170)”
“middleware.log$log_api_call$fn__65506.invoke(log.clj:164)”
“middleware.security$add_security_headers$fn__64044.invoke(security.clj:128)”
“middleware.json$wrap_json_body$fn__65211.invoke(json.clj:61)”
“middleware.json$wrap_streamed_json_response$fn__65229.invoke(json.clj:97)”
“middleware.session$bind_current_user$fn__61966$fn__61967.invoke(session.clj:193)”
“middleware.session$do_with_current_user.invokeStatic(session.clj:176)”
“middleware.session$do_with_current_user.invoke(session.clj:170)”
“middleware.session$bind_current_user$fn__61966.invoke(session.clj:192)”
“middleware.session$wrap_current_user_id$fn__61955.invoke(session.clj:161)”
“middleware.session$wrap_session_id$fn__61940.invoke(session.clj:123)”
“middleware.auth$wrap_api_key$fn__63990.invoke(auth.clj:27)”
“middleware.misc$maybe_set_site_url$fn__65533.invoke(misc.clj:56)”
“middleware.misc$bind_user_locale$fn__65536.invoke(misc.clj:72)”
“middleware.misc$add_content_type$fn__65521.invoke(misc.clj:28)”
“middleware.misc$disable_streaming_buffering$fn__65544.invoke(misc.clj:87)”),
:sql-exception-chain
[“PSQLException:”
“Message: ERROR: null value in column “before” violates not-null constraint”
“Detail: Failing row contains (7, null, {“3”:{“2”:{“native”:“write”,“schemas”:“all”}}}, 1, 2019-09-06 14:37:06.613, null).”
“SQLState: 23502”
“Error Code: 0”]}

Hi @MartinFix
There has been a couple of fixes related to saving of Permissions in version 0.33.2, so could you try that?
Also, which version of Postgres are you using?

Hi Thanks,
We did upgrade on the newest version 0.33.2 but the error still remains the same. PostgreSQL version is 9.6 as a hosted SQL database on Google Cloud.
Any other idea?
Best
Martin

@MartinFix
I have not seen this error before. I’m not quite sure what’s going on, but I would recommend that you create an issue:
https://github.com/metabase/metabase/issues/new/choose

Thanks,
I did create a bug in GitHub. Let’s see how this can be solved.

Martin

Just for reference: