hasura / hasura/graphql-engine

Server: Problems after attempt to rename a column (or add a new one)

Open
#8,688 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

c/server k/bug t/native-dbs
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

Haura console of remote DB run from Hasura CLI (served on port 9695)

Server Version:
CLI Version 2.8.3

Environment

Hasura console. 2.8.3

What is the current behaviour?

Tried to rename a column creator -> created_by in table messages
Got long error (did not read carefully, something about permissions I believe)
Cancelled operation (closed the column edit window)
... and now lots of problems: it looks like the name was changedbut not quite...

When I select messages table:

Browse query failed!
no such column exists : "created_by"

(however SQL query shows table "created_by" exists...
Whatever I try:

ALTER TABLE messages DROP creator;
ALTER TABLE messages DROP created_by;
ALTER TABLE messages
RENAME COLUMN created_by TO creator;

Results in:

source with name "default" does not exist

Tired to refresh metadata...
When I try to delete column "created_by" I got error:

{ "internal": [ { "definition": { "role": "klient", "source": "geobase", "comment": null, "permission": { "backend_only": false, "check": {}, "columns": [ "id", "is_done", "is_incoming", "is_new", "awizacja_id", "client_code", "creator", "files", "text", "created_at" ] }, "table": { "schema": "public", "name": "messages" } }, "reason": "Inconsistent object: in table \"messages\": in permission for role \"klient\": column \"creator\" does not exist", "name": "insert_permission klient in table messages in source geobase", "type": "insert_permission" }, { "definition": { "role": "zarzad", "source": "geobase", "comment": null, "permission": { "allow_aggregations": false, "computed_fields": [], "columns": [ "id", "is_done", "is_incoming", "is_new", "awizacja_id", "client_code", "creator", "files", "text", "created_at" ], "filter": {} }, "table": { "schema": "public", "name": "messages" } }, "reason": "Inconsistent object: in table \"messages\": in permission for role \"zarzad\": column \"creator\" does not exist", "name": "select_permission zarzad in table messages in source geobase", "type": "select_permission" }, { "definition": { "role": "biuro", "source": "geobase", "comment": null, "permission": { "backend_only": false, "check": {}, "columns": [ "id", "is_done", "is_incoming", "is_new", "awizacja_id", "client_code", "creator", "files", "text", "created_at" ] }, "table": { "schema": "public", "name": "messages" } }, "reason": "Inconsistent object: in table \"messages\": in permission for role \"biuro\": column \"creator\" does not exist", "name": "insert_permission biuro in table messages in source geobase", "type": "insert_permission" }, { "definition": { "name": "Insert awizacja history", "query": "mutation insertAwiHistory ($awizacja_id: String, $client_code: String, $created_by: String, $text: String) {\n\tinsert_awi_skup_history(objects: {awizacja_id:$awizacja_id,client_code:$client_code,created_by:$created_by,message:{data:{text:$text,is_new:true,awizacja_id:$awizacja_id,client_code:$client_code,creator:$created_by}}}) {\n\t\taffected_rows\n\t\treturning {\n\t\t\tawizacja_id\n\t\t\tclient_code\n\t\t\tcreated_by\n\t\t\tmessage {\n\t\t\t\ttext\n\t\t\t\tawizacja_id\n\t\t\t\tclient_code\n\t\t\t\tcreator\n\t\t\t}\n\t\t}\n\t}\n}\n" }, "reason": "Inconsistent object: In query collection \"allowed-queries\" the query \"Insert awizacja history\" is invalid with the following error(s): \"$.insert_awi_skup_history.returning.message.creator: field 'creator' not found in object 'messages'\". This query is being used in the following REST endpoint(s): \"Insert awizacja history\". This query is in allowlist.", "name": "query_collections Insert awizacja history in allowed-queries", "type": "query_collections" }, { "definition": { "role": "darsoft", "source": "geobase", "comment": null, "permission": { "backend_only": false, "check": {}, "columns": [ "id", "is_done", "is_incoming", "is_new", "awizacja_id", "client_code", "creator", "files", "text", "created_at" ] }, "table": { "schema": "public", "name": "messages" } }, "reason": "Inconsistent object: in table \"messages\": in permission for role \"darsoft\": column \"creator\" does not exist", "name": "insert_permission darsoft in table messages in source geobase", "type": "insert_permission" }, { "definition": { "role": "biuro", "source": "geobase", "comment": null, "permission": { "allow_aggregations": false, "computed_fields": [], "columns": [ "id", "is_done", "is_incoming", "is_new", "awizacja_id", "client_code", "creator", "files", "text", "created_at" ], "filter": {} }, "table": { "schema": "public", "name": "messages" } }, "reason": "Inconsistent object: in table \"messages\": in permission for role \"biuro\": column \"creator\" does not exist", "name": "select_permission biuro in table messages in source geobase", "type": "select_permission" }, { "definition": { "role": "klient", "source": "geobase", "comment": null, "permission": { "allow_aggregations": false, "computed_fields": [], "columns": [ "id", "is_done", "is_incoming", "is_new", "awizacja_id", "client_code", "creator", "files", "text", "created_at" ], "filter": {} }, "table": { "schema": "public", "name": "messages" } }, "reason": "Inconsistent object: in table \"messages\": in permission for role \"klient\": column \"creator\" does not exist", "name": "select_permission klient in table messages in source geobase", "type": "select_permission" }, { "definition": { "role": "zarzad", "source": "geobase", "comment": null, "permission": { "backend_only": false, "check": {}, "columns": [ "awizacja_id", "text", "files", "creator", "is_new", "is_done", "created_at", "is_incoming", "id", "client_code" ] }, "table": { "schema": "public", "name": "messages" } }, "reason": "Inconsistent object: in table \"messages\": in permission for role \"zarzad\": column \"creator\" does not exist", "name": "insert_permission zarzad in table messages in source geobase", "type": "insert_permission" }, { "definition": { "role": "darsoft", "source": "geobase", "comment": null, "permission": { "allow_aggregations": false, "computed_fields": [], "columns": [ "id", "is_done", "is_incoming", "is_new", "awizacja_id", "client_code", "creator", "files", "text", "created_at" ], "filter": {} }, "table": { "schema": "public", "name": "messages" } }, "reason": "Inconsistent object: in table \"messages\": in permission for role \"darsoft\": column \"creator\" does not exist", "name": "select_permission darsoft in table messages in source geobase", "type": "select_permission" } ], "path": "$[0]", "error": "cannot continue due to newly found inconsistent metadata", "code": "unexpected" }

But actually the column looks gone in console.

When I try to create column "created_by" again I got:

Adding column failed
{ "internal": [ { "definition": { "role": "klient", "source": "geobase", "comment": null, "permission": { "backend_only": false, "check": {}, "columns": [ "id", "is_done", "is_incoming", "is_new", "awizacja_id", "client_code", "creator", "files", "text", "created_at" ] }, "table": { "schema": "public", "name": "messages" } }, "reason": "Inconsistent object: in table \"messages\": in permission for role \"klient\": column \"creator\" does not exist", "name": "insert_permission klient in table messages in source geobase", "type": "insert_permission" }, { "definition": { "role": "zarzad", "source": "geobase", "comment": null, "permission": { "allow_aggregations": false, "computed_fields": [], "columns": [ "id", "is_done", "is_incoming", "is_new", "awizacja_id", "client_code", "creator", "files", "text", "created_at" ], "filter": {} }, "table": { "schema": "public", "name": "messages" } }, "reason": "Inconsistent object: in table \"messages\": in permission for role \"zarzad\": column \"creator\" does not exist", "name": "select_permission zarzad in table messages in source geobase", "type": "select_permission" }, { "definition": { "role": "biuro", "source": "geobase", "comment": null, "permission": { "backend_only": false, "check": {}, "columns": [ "id", "is_done", "is_incoming", "is_new", "awizacja_id", "client_code", "creator", "files", "text", "created_at" ] }, "table": { "schema": "public", "name": "messages" } }, "reason": "Inconsistent object: in table \"messages\": in permission for role \"biuro\": column \"creator\" does not exist", "name": "insert_permission biuro in table messages in source geobase", "type": "insert_permission" }, { "definition": { "name": "Insert awizacja history", "query": "mutation insertAwiHistory ($awizacja_id: String, $client_code: String, $created_by: String, $text: String) {\n\tinsert_awi_skup_history(objects: {awizacja_id:$awizacja_id,client_code:$client_code,created_by:$created_by,message:{data:{text:$text,is_new:true,awizacja_id:$awizacja_id,client_code:$client_code,creator:$created_by}}}) {\n\t\taffected_rows\n\t\treturning {\n\t\t\tawizacja_id\n\t\t\tclient_code\n\t\t\tcreated_by\n\t\t\tmessage {\n\t\t\t\ttext\n\t\t\t\tawizacja_id\n\t\t\t\tclient_code\n\t\t\t\tcreator\n\t\t\t}\n\t\t}\n\t}\n}\n" }, "reason": "Inconsistent object: In query collection \"allowed-queries\" the query \"Insert awizacja history\" is invalid with the following error(s): \"$.insert_awi_skup_history.returning.message.creator: field 'creator' not found in object 'messages'\". This query is being used in the following REST endpoint(s): \"Insert awizacja history\". This query is in allowlist.", "name": "query_collections Insert awizacja history in allowed-queries", "type": "query_collections" }, { "definition": { "role": "darsoft", "source": "geobase", "comment": null, "permission": { "backend_only": false, "check": {}, "columns": [ "id", "is_done", "is_incoming", "is_new", "awizacja_id", "client_code", "creator", "files", "text", "created_at" ] }, "table": { "schema": "public", "name": "messages" } }, "reason": "Inconsistent object: in table \"messages\": in permission for role \"darsoft\": column \"creator\" does not exist", "name": "insert_permission darsoft in table messages in source geobase", "type": "insert_permission" }, { "definition": { "role": "biuro", "source": "geobase", "comment": null, "permission": { "allow_aggregations": false, "computed_fields": [], "columns": [ "id", "is_done", "is_incoming", "is_new", "awizacja_id", "client_code", "creator", "files", "text", "created_at" ], "filter": {} }, "table": { "schema": "public", "name": "messages" } }, "reason": "Inconsistent object: in table \"messages\": in permission for role \"biuro\": column \"creator\" does not exist", "name": "select_permission biuro in table messages in source geobase", "type": "select_permission" }, { "definition": { "role": "klient", "source": "geobase", "comment": null, "permission": { "allow_aggregations": false, "computed_fields": [], "columns": [ "id", "is_done", "is_incoming", "is_new", "awizacja_id", "client_code", "creator", "files", "text", "created_at" ], "filter": {} }, "table": { "schema": "public", "name": "messages" } }, "reason": "Inconsistent object: in table \"messages\": in permission for role \"klient\": column \"creator\" does not exist", "name": "select_permission klient in table messages in source geobase", "type": "select_permission" }, { "definition": { "role": "zarzad", "source": "geobase", "comment": null, "permission": { "backend_only": false, "check": {}, "columns": [ "awizacja_id", "text", "files", "creator", "is_new", "is_done", "created_at", "is_incoming", "id", "client_code" ] }, "table": { "schema": "public", "name": "messages" } }, "reason": "Inconsistent object: in table \"messages\": in permission for role \"zarzad\": column \"creator\" does not exist", "name": "insert_permission zarzad in table messages in source geobase", "type": "insert_permission" }, { "definition": { "role": "darsoft", "source": "geobase", "comment": null, "permission": { "allow_aggregations": false, "computed_fields": [], "columns": [ "id", "is_done", "is_incoming", "is_new", "awizacja_id", "client_code", "creator", "files", "text", "created_at" ], "filter": {} }, "table": { "schema": "public", "name": "messages" } }, "reason": "Inconsistent object: in table \"messages\": in permission for role \"darsoft\": column \"creator\" does not exist", "name": "select_permission darsoft in table messages in source geobase", "type": "select_permission" } ], "path": "$[0]", "error": "cannot continue due to newly found inconsistent metadata", "code": "unexpected" }

How can I clean this mess?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the column rename or add operation in the Hasura Console through the CLI-served server, then inspect the reported SQL, permission, query-collection, and metadata errors. Done means cancelling or completing the operation leaves the messages table, permissions, allowed query, and metadata consistent so browsing, SQL changes, refresh, and column creation work again.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, postgres
Domain
api, authorization, backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.