server: include more detail in inconsistent metadata error messages (fix #6684)

GitOrigin-RevId: 1a0d8fa2b465320e9ab4ea43259d0e8d92364473
This commit is contained in:
Abby Sassel 2021-05-19 06:01:54 +01:00 committed by hasura-bot
parent a7639145fe
commit 3ba5d1e540
29 changed files with 617 additions and 533 deletions

View File

@ -18,6 +18,7 @@
- server: explaining/analyzing a query now works for mssql sources
- server: fix MSSQL multiplexed subscriptions (fix #6887)
- server: fix bug preventing tables with the same name in different sources
- server: include more detail in inconsistent metadata error messages (fix #6684)
- console: add union types to remote schema permissions
- console: read-only modify page for mssql
- console: filter out partitions from track table list and display partition info

View File

@ -366,7 +366,7 @@ func TestClient_GetInconsistentMetadata(t *testing.T) {
}{
{
name: "can get inconsistent metadata",
want: bytes.NewReader([]byte(`{"is_consistent":false,"inconsistent_objects":[{"definition":{"schema":"public","name":"test"},"reason":"no such table/view exists in source: \"test\"","type":"table"}]}`)),
want: bytes.NewReader([]byte(`{"is_consistent":false,"inconsistent_objects":[{"definition":{"name":"test", "schema":"public"}, "name":"table test in source default", "reason":"Inconsistent object: no such table/view exists in source: \"test\"", "type":"table"}]}`)),
fields: fields{
Client: testutil.NewHttpcClient(t, portHasuraLatest, nil),
path: "v1/metadata",

View File

@ -86,8 +86,9 @@ func TestClientCommonMetadataOps_V2ReplaceMetadata(t *testing.T) {
"schema": "default",
"name": "test"
},
"reason": "no such table/view exists in source: \"default.test\"",
"type": "table"
"name":"table default.test in source default",
"reason":"Inconsistent object: no such table/view exists in source: \"default.test\"",
"type":"table"
}
]
}`

View File

@ -93,6 +93,7 @@ data Code
| BadRequest
| MethodNotAllowed
| Conflict
| InvalidConfiguration
-- Graphql error
| NoTables
| ValidationFailed
@ -160,6 +161,7 @@ instance Show Code where
MethodNotAllowed -> "method-not-allowed"
Conflict -> "conflict"
BigQueryError -> "bigquery-error"
InvalidConfiguration -> "invalid-configuration"
ActionWebhookCode t -> T.unpack t
CustomCode t -> T.unpack t

View File

@ -202,14 +202,14 @@ buildSchemaCacheRule env = proc (metadata, invalidationKeys) -> do
endpoints = buildEndpointsTrie (M.elems $ _boEndpoints resolvedOutputs)
duplicateF md = DuplicateRestVariables ("Duplicate variables found in endpoint path " <> (ceUrlTxt md)) (endpointObject md)
duplicateF md = DuplicateRestVariables (ceUrlTxt md) (endpointObject md)
duplicateRestVariables = map duplicateF $ filter duplicateVariables (M.elems $ _boEndpoints resolvedOutputs)
invalidF md = InvalidRestSegments ("Empty segments or unnamed variables are not allowed: " <> (ceUrlTxt md)) (endpointObject md)
invalidF md = InvalidRestSegments (ceUrlTxt md) (endpointObject md)
invalidRestSegments = map invalidF $ filter hasInvalidSegments (M.elems $ _boEndpoints resolvedOutputs)
ambiguousF' ep = MetadataObject (endpointObjId ep) (toJSON ep)
ambiguousF mds = AmbiguousRestEndpoints ("Ambiguous URL paths: " <> commaSeparated (map _ceUrl mds)) (map ambiguousF' mds)
ambiguousF mds = AmbiguousRestEndpoints (commaSeparated $ map _ceUrl mds) (map ambiguousF' mds)
ambiguousRestEndpoints = map (ambiguousF . S.elems . snd) $ ambiguousPathsGrouped endpoints
returnA -< SchemaCache

View File

@ -178,12 +178,12 @@ imObjectIds = \case
imReason :: InconsistentMetadata -> Text
imReason = \case
InconsistentObject reason _ _ -> reason
ConflictingObjects reason _ -> reason
DuplicateObjects objectId _ -> "multiple definitions for " <> moiName objectId
DuplicateRestVariables reason _ -> reason
InvalidRestSegments reason _ -> reason
AmbiguousRestEndpoints reason _ -> reason
InconsistentObject reason _ _ -> "Inconsistent object: " <> reason
ConflictingObjects reason _ -> "Conflicting objects: " <> reason
DuplicateObjects objectId _ -> "Multiple definitions for: " <> moiName objectId
DuplicateRestVariables reason _ -> "Duplicate variables found in endpoint path: " <> reason
InvalidRestSegments reason _ -> "Empty segments or unnamed variables are not allowed: " <> reason
AmbiguousRestEndpoints reason _ -> "Ambiguous URL paths: " <> reason
-- | Builds a map from each unique metadata object id to the inconsistencies associated with it.
-- Note that a single inconsistency can involve multiple metadata objects, so the same inconsistency
@ -197,7 +197,7 @@ instance ToJSON InconsistentMetadata where
toJSON inconsistentMetadata = object (("reason" .= imReason inconsistentMetadata) : extraFields)
where
extraFields = case inconsistentMetadata of
InconsistentObject _ internal metadata -> metadataObjectFields internal metadata
InconsistentObject _ message metadata -> metadataObjectFields message metadata
ConflictingObjects _ metadatas ->
[ "objects" .= map (object . metadataObjectFields Nothing) metadatas ]
DuplicateObjects objectId definitions ->
@ -208,7 +208,8 @@ instance ToJSON InconsistentMetadata where
InvalidRestSegments _ md -> metadataObjectFields Nothing md
AmbiguousRestEndpoints _ mds -> [ "conflicts" .= map _moDefinition mds ]
metadataObjectFields (maybeInternal :: Maybe Value) (MetadataObject objectId definition) =
metadataObjectFields (maybeMessage :: Maybe Value) (MetadataObject objectId definition) =
[ "type" .= String (moiTypeName objectId)
, "name" .= String (moiName objectId)
, "definition" .= definition ]
<> maybe [] (\internal -> ["internal" .= internal]) maybeInternal
<> maybe [] (\message -> ["message" .= message]) maybeMessage

View File

@ -234,7 +234,7 @@ buildSchemaCacheFor objectId metadataModifier = do
for_ (M.lookup objectId newInconsistentObjects) $ \matchingObjects -> do
let reasons = commaSeparated $ imReason <$> matchingObjects
throwError (err400 ConstraintViolation reasons) { qeInternal = Just $ toJSON matchingObjects }
throwError (err400 InvalidConfiguration reasons) { qeInternal = Just $ toJSON matchingObjects }
unless (null newInconsistentObjects) $
throwError (err400 Unexpected "cannot continue due to new inconsistent metadata")

View File

@ -3,51 +3,56 @@ url: /v1/query
status: 400
response:
internal:
- definition:
input_objects:
objects:
- name: User
relationships:
- remote_table:
schema: public
name: user
name: Names
source: default
type: array
field_mapping:
names: name
description:
fields:
- arguments:
name: user_id
type: uuid!
description:
- arguments:
name: names
type: '[String!]'
description:
scalars:
enums:
reason: validation for the given custom types failed because the type of the field
"names" for relationship "Names" in object type "User" is a list type
type: custom_types
- definition:
input_objects:
objects:
- name: User
relationships:
- remote_table:
schema: public
name: user
name: Names
source: default
type: array
field_mapping:
names: name
description:
fields:
- arguments:
name: user_id
type: uuid!
description:
- arguments:
name: names
type: "[String!]"
description:
scalars:
enums:
reason:
'Inconsistent object: validation for the given custom types failed because
the type of the field "names" for relationship "Names" in object type "User"
is a list type'
name: custom_types custom_types
type: custom_types
path: $.args
error: validation for the given custom types failed because the type of the field
"names" for relationship "Names" in object type "User" is a list type
code: constraint-violation
error:
'Inconsistent object: validation for the given custom types failed because
the type of the field "names" for relationship "Names" in object type "User" is
a list type'
code: invalid-configuration
query:
type: set_custom_types
args:
objects:
- name: User
fields:
- name: user_id
type: uuid!
- name: names
type: '[String!]'
relationships:
- name: Names
type: array
remote_table: user
field_mapping:
names: name
- name: User
fields:
- name: user_id
type: uuid!
- name: names
type: "[String!]"
relationships:
- name: Names
type: array
remote_table: user
field_mapping:
names: name

View File

@ -3,59 +3,64 @@ url: /v1/query
status: 400
response:
internal:
- definition:
input_objects:
- name: UserInput
description:
fields:
- name: name
type: String!
description:
- name: id
type: uuid!
description:
objects:
- name: User
relationships:
description:
fields:
- arguments:
name: user_id
type: uuid!
description:
- arguments:
name: location
type: geography
description:
- arguments:
name: unknown_pgtype
type: unknown_type
description:
scalars:
enums:
reason: validation for the given custom types failed because the type "unknown_type"
for field "unknown_pgtype" in object type "User" does not exist
type: custom_types
- definition:
input_objects:
- name: UserInput
description:
fields:
- name: name
type: String!
description:
- name: id
type: uuid!
description:
objects:
- name: User
relationships:
description:
fields:
- arguments:
name: user_id
type: uuid!
description:
- arguments:
name: location
type: geography
description:
- arguments:
name: unknown_pgtype
type: unknown_type
description:
scalars:
enums:
reason:
'Inconsistent object: validation for the given custom types failed because
the type "unknown_type" for field "unknown_pgtype" in object type "User" does
not exist'
name: custom_types custom_types
type: custom_types
path: $.args
error: validation for the given custom types failed because the type "unknown_type"
for field "unknown_pgtype" in object type "User" does not exist
code: constraint-violation
error:
'Inconsistent object: validation for the given custom types failed because
the type "unknown_type" for field "unknown_pgtype" in object type "User" does
not exist'
code: invalid-configuration
query:
type: set_custom_types
args:
objects:
- name: User
fields:
- name: user_id
type: uuid!
- name: location
type: geography
- name: unknown_pgtype
type: unknown_type
- name: User
fields:
- name: user_id
type: uuid!
- name: location
type: geography
- name: unknown_pgtype
type: unknown_type
input_objects:
- name: UserInput
fields:
- name: name
type: String!
- name: id
type: uuid!
- name: UserInput
fields:
- name: name
type: String!
- name: id
type: uuid!

View File

@ -3,18 +3,19 @@ url: /v1/query
status: 400
response:
internal:
- definition:
definition:
query:
collection_name: test_collection
query_name: simple_query
url: foo/:id/bar/:id
methods:
- GET
name: duplicate
comment:
reason: Duplicate variables found in endpoint path foo/:id/bar/:id
type: endpoint
- definition:
definition:
query:
collection_name: test_collection
query_name: simple_query
url: foo/:id/bar/:id
methods:
- GET
name: duplicate
comment:
reason: "Duplicate variables found in endpoint path: foo/:id/bar/:id"
name: endpoint duplicate
type: endpoint
path: $.args
error: cannot continue due to new inconsistent metadata
code: unexpected

View File

@ -3,18 +3,19 @@ url: /v1/query
status: 400
response:
internal:
- definition:
definition:
query:
collection_name: test_collection
query_name: simple_query
url: foo/:/bar
methods:
- GET
name: foo
comment:
reason: 'Empty segments or unnamed variables are not allowed: foo/:/bar'
type: endpoint
- definition:
definition:
query:
collection_name: test_collection
query_name: simple_query
url: foo/:/bar
methods:
- GET
name: foo
comment:
reason: "Empty segments or unnamed variables are not allowed: foo/:/bar"
name: endpoint foo
type: endpoint
path: $.args
error: cannot continue due to new inconsistent metadata
code: unexpected

View File

@ -3,18 +3,19 @@ url: /v1/query
status: 400
response:
internal:
- definition:
definition:
query:
collection_name: test_collection
query_name: simple_query
url: foo//bar
methods:
- GET
name: foo
comment:
reason: 'Empty segments or unnamed variables are not allowed: foo//bar'
type: endpoint
- definition:
definition:
query:
collection_name: test_collection
query_name: simple_query
url: foo//bar
methods:
- GET
name: foo
comment:
reason: "Empty segments or unnamed variables are not allowed: foo//bar"
name: endpoint foo
type: endpoint
path: $.args
error: cannot continue due to new inconsistent metadata
code: unexpected

View File

@ -3,18 +3,21 @@ url: /v1/query
status: 400
response:
internal:
- definition:
definition:
query:
collection_name: test_collection
query_name: simple_subscription
url: foo/bar/subscribe
methods:
- GET
name: foo
comment:
reason: 'in endpoint foo: query with name simple_subscription is a subscription'
type: endpoint
- definition:
definition:
query:
collection_name: test_collection
query_name: simple_subscription
url: foo/bar/subscribe
methods:
- GET
name: foo
comment:
reason:
"Inconsistent object: in endpoint foo: query with name simple_subscription
is a subscription"
name: endpoint foo
type: endpoint
path: $.args
error: cannot continue due to new inconsistent metadata
code: unexpected

View File

@ -3,18 +3,19 @@ url: /v1/query
status: 400
response:
internal:
- definition:
definition:
query:
collection_name: test_collection
query_name: simple_query
url: foo/
methods:
- GET
name: trailing
comment:
reason: 'Empty segments or unnamed variables are not allowed: foo/'
type: endpoint
- definition:
definition:
query:
collection_name: test_collection
query_name: simple_query
url: foo/
methods:
- GET
name: trailing
comment:
reason: "Empty segments or unnamed variables are not allowed: foo/"
name: endpoint trailing
type: endpoint
path: $.args
error: cannot continue due to new inconsistent metadata
code: unexpected

View File

@ -5,19 +5,23 @@
status: 400
response:
internal:
- definition:
schema: public
name: stable_func1
reason: 'in function "stable_func1": the function "stable_func1" cannot be tracked
because the function was requested to be exposed as a mutation, but is not
marked VOLATILE. Maybe the function was given the wrong volatility when it
was defined?'
type: function
- definition:
schema: public
name: stable_func1
reason:
'Inconsistent object: in function "stable_func1": the function "stable_func1"
cannot be tracked because the function was requested to be exposed as a mutation,
but is not marked VOLATILE. Maybe the function was given the wrong volatility
when it was defined?'
name: function stable_func1 in source default
type: function
path: $.args
error: 'in function "stable_func1": the function "stable_func1" cannot be tracked
because the function was requested to be exposed as a mutation, but is not marked
VOLATILE. Maybe the function was given the wrong volatility when it was defined?'
code: constraint-violation
error:
'Inconsistent object: in function "stable_func1": the function "stable_func1"
cannot be tracked because the function was requested to be exposed as a mutation,
but is not marked VOLATILE. Maybe the function was given the wrong volatility
when it was defined?'
code: invalid-configuration
query:
version: 2
type: track_function
@ -25,4 +29,3 @@
function: stable_func1
configuration:
exposed_as: mutation

View File

@ -15,18 +15,21 @@
status: 400
response:
internal:
- definition:
schema: public
name: get_session_var_value
reason: 'in function "get_session_var_value": the function "get_session_var_value"
cannot be tracked because given session argument "random" not the input argument
of the function'
type: function
- definition:
schema: public
name: get_session_var_value
reason:
'Inconsistent object: in function "get_session_var_value": the function
"get_session_var_value" cannot be tracked because given session argument "random"
not the input argument of the function'
name: function get_session_var_value in source default
type: function
path: $.args
error: 'in function "get_session_var_value": the function "get_session_var_value"
error:
'Inconsistent object: in function "get_session_var_value": the function "get_session_var_value"
cannot be tracked because given session argument "random" not the input argument
of the function'
code: constraint-violation
code: invalid-configuration
query:
version: 2
type: track_function
@ -40,18 +43,21 @@
status: 400
response:
internal:
- definition:
schema: public
name: get_session_var_value
reason: 'in function "get_session_var_value": the function "get_session_var_value"
cannot be tracked because given session argument "session_var" is not of type
json'
type: function
- definition:
schema: public
name: get_session_var_value
reason:
'Inconsistent object: in function "get_session_var_value": the function
"get_session_var_value" cannot be tracked because given session argument "session_var"
is not of type json'
name: function get_session_var_value in source default
type: function
path: $.args
error: 'in function "get_session_var_value": the function "get_session_var_value"
error:
'Inconsistent object: in function "get_session_var_value": the function "get_session_var_value"
cannot be tracked because given session argument "session_var" is not of type
json'
code: constraint-violation
code: invalid-configuration
query:
version: 2
type: track_function

View File

@ -50,7 +50,8 @@ inconsistent_objects:
- definition:
schema: public
name: article
reason: 'no such table/view exists in source: "article"'
name: table article in source default
reason: 'Inconsistent object: no such table/view exists in source: "article"'
type: table
- definition:
using:
@ -65,8 +66,9 @@ inconsistent_objects:
table:
schema: public
name: author
name: array_relation articles in table author in source default
reason: >-
in table "author": in relationship "articles": table "article" does not exist
Inconsistent object: in table "author": in relationship "articles": table "article" does not exist
type: array_relation
# Teardown

View File

@ -24,22 +24,23 @@
function: full_name
response:
internal:
- definition:
definition:
function:
- definition:
definition:
function:
schema: public
name: full_name
name: first_name
source: default
comment:
table:
schema: public
name: full_name
name: first_name
source: default
comment:
table:
schema: public
name: author
reason: field definition conflicts with postgres column
type: computed_field
name: author
reason: "Inconsistent object: field definition conflicts with postgres column"
name: computed_field first_name in table author in source default
type: computed_field
path: $.args
error: field definition conflicts with postgres column
code: constraint-violation
error: "Inconsistent object: field definition conflicts with postgres column"
code: invalid-configuration
- description: Try adding computed field with invalid function
url: /v1/query
status: 400
@ -52,24 +53,27 @@
function: random_function
response:
internal:
- definition:
definition:
function:
- definition:
definition:
function:
schema: public
name: random_function
name: full_name
source: default
comment:
table:
schema: public
name: random_function
name: full_name
source: default
comment:
table:
schema: public
name: author
reason: 'in table "author": in computed field "full_name": no such function
exists in postgres : "random_function"'
type: computed_field
name: author
reason:
'Inconsistent object: in table "author": in computed field "full_name":
no such function exists in postgres : "random_function"'
name: computed_field full_name in table author in source default
type: computed_field
path: $.args
error: 'in table "author": in computed field "full_name": no such function exists
in postgres : "random_function"'
code: constraint-violation
error:
'Inconsistent object: in table "author": in computed field "full_name": no
such function exists in postgres : "random_function"'
code: invalid-configuration
- description: Try adding computed field with invalid table argument name
url: /v1/query
status: 400
@ -83,27 +87,30 @@
table_argument: random
response:
internal:
- definition:
definition:
function:
- definition:
definition:
function:
schema: public
name: full_name
table_argument: random
name: full_name
source: default
comment:
table:
schema: public
name: full_name
table_argument: random
name: full_name
source: default
comment:
table:
schema: public
name: author
reason: 'in table "author": in computed field "full_name": the computed field
"full_name" cannot be added to table "author" because "random" is not an input
argument of the function "full_name"'
type: computed_field
name: author
reason:
'Inconsistent object: in table "author": in computed field "full_name":
the computed field "full_name" cannot be added to table "author" because "random"
is not an input argument of the function "full_name"'
name: computed_field full_name in table author in source default
type: computed_field
path: $.args
error: 'in table "author": in computed field "full_name": the computed field "full_name"
cannot be added to table "author" because "random" is not an input argument
of the function "full_name"'
code: constraint-violation
error:
'Inconsistent object: in table "author": in computed field "full_name": the
computed field "full_name" cannot be added to table "author" because "random"
is not an input argument of the function "full_name"'
code: invalid-configuration
- description: Try adding computed field with a volatile function
url: /v1/query
status: 400
@ -117,31 +124,34 @@
table_argument: random
response:
internal:
- definition:
definition:
function:
- definition:
definition:
function:
schema: public
name: fetch_articles_volatile
table_argument: random
name: get_articles
source: default
comment:
table:
schema: public
name: fetch_articles_volatile
table_argument: random
name: get_articles
source: default
comment:
table:
schema: public
name: author
reason: "in table \"author\": in computed field \"get_articles\": the computed\
\ field \"get_articles\" cannot be added to table \"author\" for the following\
\ reasons:\n • the function \"fetch_articles_volatile\" is of type VOLATILE;\
\ cannot be added as a computed field\n • \"random\" is not an input argument\
\ of the function \"fetch_articles_volatile\"\n"
type: computed_field
name: author
reason:
"Inconsistent object: in table \"author\": in computed field \"get_articles\"\
: the computed field \"get_articles\" cannot be added to table \"author\" for\
\ the following reasons:\n • the function \"fetch_articles_volatile\" is of\
\ type VOLATILE; cannot be added as a computed field\n • \"random\" is not\
\ an input argument of the function \"fetch_articles_volatile\"\n"
name: computed_field get_articles in table author in source default
type: computed_field
path: $.args
error: "in table \"author\": in computed field \"get_articles\": the computed\
\ field \"get_articles\" cannot be added to table \"author\" for the following\
\ reasons:\n • the function \"fetch_articles_volatile\" is of type VOLATILE;\
\ cannot be added as a computed field\n • \"random\" is not an input argument\
\ of the function \"fetch_articles_volatile\"\n"
code: constraint-violation
error:
"Inconsistent object: in table \"author\": in computed field \"get_articles\"\
: the computed field \"get_articles\" cannot be added to table \"author\" for\
\ the following reasons:\n • the function \"fetch_articles_volatile\" is of type\
\ VOLATILE; cannot be added as a computed field\n • \"random\" is not an input\
\ argument of the function \"fetch_articles_volatile\"\n"
code: invalid-configuration
- description: Try adding a computed field with a function with no input arguments
url: /v1/query
status: 400
@ -154,29 +164,63 @@
function: hello_world
response:
internal:
- definition:
definition:
function:
- definition:
definition:
function:
schema: public
name: hello_world
name: hello_world
source: default
comment:
table:
schema: public
name: hello_world
name: hello_world
source: default
comment:
table:
schema: public
name: author
reason: 'in table "author": in computed field "hello_world": the computed field
"hello_world" cannot be added to table "author" because the function "hello_world"
has no input arguments'
type: computed_field
name: author
reason:
'Inconsistent object: in table "author": in computed field "hello_world":
the computed field "hello_world" cannot be added to table "author" because the
function "hello_world" has no input arguments'
name: computed_field hello_world in table author in source default
type: computed_field
path: $.args
error: 'in table "author": in computed field "hello_world": the computed field
"hello_world" cannot be added to table "author" because the function "hello_world"
has no input arguments'
code: constraint-violation
error:
'Inconsistent object: in table "author": in computed field "hello_world":
the computed field "hello_world" cannot be added to table "author" because the
function "hello_world" has no input arguments'
code: invalid-configuration
- description: Try adding a computed field with first argument as table argument
url: /v1/query
status: 400
response:
internal:
- definition:
definition:
function:
schema: public
name: fetch_articles
name: get_articles
source: default
comment:
table:
schema: public
name: author
reason:
"Inconsistent object: in table \"author\": in computed field \"get_articles\"\
: the computed field \"get_articles\" cannot be added to table \"author\" for\
\ the following reasons:\n • first argument of the function \"fetch_articles\"\
\ is not COMPOSITE type\n • first argument of the function \"fetch_articles\"\
\ of type \"pg_catalog.text\" is not the table to which the computed field is\
\ being added\n"
name: computed_field get_articles in table author in source default
type: computed_field
path: $.args
error:
"Inconsistent object: in table \"author\": in computed field \"get_articles\"\
: the computed field \"get_articles\" cannot be added to table \"author\" for\
\ the following reasons:\n • first argument of the function \"fetch_articles\"\
\ is not COMPOSITE type\n • first argument of the function \"fetch_articles\"\
\ of type \"pg_catalog.text\" is not the table to which the computed field is\
\ being added\n"
code: invalid-configuration
query:
type: add_computed_field
args:
@ -184,32 +228,6 @@
name: get_articles
definition:
function: fetch_articles
response:
internal:
- definition:
definition:
function:
schema: public
name: fetch_articles
name: get_articles
source: default
comment:
table:
schema: public
name: author
reason: "in table \"author\": in computed field \"get_articles\": the computed\
\ field \"get_articles\" cannot be added to table \"author\" for the following\
\ reasons:\n • first argument of the function \"fetch_articles\" is not COMPOSITE\
\ type\n • first argument of the function \"fetch_articles\" of type \"pg_catalog.text\"\
\ is not the table to which the computed field is being added\n"
type: computed_field
path: $.args
error: "in table \"author\": in computed field \"get_articles\": the computed\
\ field \"get_articles\" cannot be added to table \"author\" for the following\
\ reasons:\n • first argument of the function \"fetch_articles\" is not COMPOSITE\
\ type\n • first argument of the function \"fetch_articles\" of type \"pg_catalog.text\"\
\ is not the table to which the computed field is being added\n"
code: constraint-violation
- description: Try adding a computed field with an invalid session argument name
url: /v1/query
status: 400
@ -223,27 +241,30 @@
session_argument: random
response:
internal:
- definition:
definition:
function:
- definition:
definition:
function:
schema: public
name: full_name
session_argument: random
name: full_name
source: default
comment:
table:
schema: public
name: full_name
session_argument: random
name: full_name
source: default
comment:
table:
schema: public
name: author
reason: 'in table "author": in computed field "full_name": the computed field
"full_name" cannot be added to table "author" because "random" is not an input
argument of the function "full_name"'
type: computed_field
name: author
reason:
'Inconsistent object: in table "author": in computed field "full_name": the computed field
"full_name" cannot be added to table "author" because "random" is not an input
argument of the function "full_name"'
name: computed_field full_name in table author in source default
type: computed_field
path: $.args
error: 'in table "author": in computed field "full_name": the computed field "full_name"
error:
'Inconsistent object: in table "author": in computed field "full_name": the computed field "full_name"
cannot be added to table "author" because "random" is not an input argument
of the function "full_name"'
code: constraint-violation
code: invalid-configuration
- description: Try adding a computed field with a non-JSON session argument
url: /v1/query
status: 400
@ -258,25 +279,28 @@
session_argument: search
response:
internal:
- definition:
definition:
function:
- definition:
definition:
function:
schema: public
name: fetch_articles
session_argument: search
table_argument: author_row
name: fetch_articles
source: default
comment:
table:
schema: public
name: fetch_articles
session_argument: search
table_argument: author_row
name: fetch_articles
source: default
comment:
table:
schema: public
name: author
reason: 'in table "author": in computed field "fetch_articles": the computed
field "fetch_articles" cannot be added to table "author" because "search"
argument of the function "fetch_articles" is not of type JSON'
type: computed_field
name: author
reason:
'Inconsistent object: in table "author": in computed field "fetch_articles": the computed
field "fetch_articles" cannot be added to table "author" because "search"
argument of the function "fetch_articles" is not of type JSON'
name: computed_field fetch_articles in table author in source default
type: computed_field
path: $.args
error: 'in table "author": in computed field "fetch_articles": the computed field
error:
'Inconsistent object: in table "author": in computed field "fetch_articles": the computed field
"fetch_articles" cannot be added to table "author" because "search" argument
of the function "fetch_articles" is not of type JSON'
code: constraint-violation
code: invalid-configuration

View File

@ -55,13 +55,14 @@
table:
schema: public
name: author
reason: 'in table "author": in permission for role "user": computed field "random"
does not exist'
reason: 'Inconsistent object: in table "author": in permission for role "user":
computed field "random" does not exist'
name: select_permission user in table author in source default
type: select_permission
path: $.args
error: 'in table "author": in permission for role "user": computed field "random"
does not exist'
code: constraint-violation
error: 'Inconsistent object: in table "author": in permission for role "user": computed
field "random" does not exist'
code: invalid-configuration
- description: Create select permission with computed field which returns a set of
table
url: /v1/query
@ -93,15 +94,16 @@
table:
schema: public
name: author
reason: 'in table "author": in permission for role "user": select permissions
on computed field "get_articles" are auto-derived from the permissions on
its returning table "article" and cannot be specified manually'
reason: 'Inconsistent object: in table "author": in permission for role "user":
select permissions on computed field "get_articles" are auto-derived from the
permissions on its returning table "article" and cannot be specified manually'
name: select_permission user in table author in source default
type: select_permission
path: $.args
error: 'in table "author": in permission for role "user": select permissions on
computed field "get_articles" are auto-derived from the permissions on its returning
table "article" and cannot be specified manually'
code: constraint-violation
error: 'Inconsistent object: in table "author": in permission for role "user": select
permissions on computed field "get_articles" are auto-derived from the permissions
on its returning table "article" and cannot be specified manually'
code: invalid-configuration
- description: Create select permission on article table
url: /v1/query
status: 200

View File

@ -4,22 +4,24 @@ status: 200
response:
is_consistent: false
inconsistent_objects:
- definition:
schema: public
name: foobar
reason: 'no such table/view exists in source: "foobar"'
type: table
- definition:
using:
foreign_key_constraint_on: author_id
name: author
source: default
comment:
table:
- definition:
schema: public
name: article
reason: table "author" is not tracked
type: object_relation
name: foobar
reason: 'Inconsistent object: no such table/view exists in source: "foobar"'
name: table foobar in source default
type: table
- definition:
using:
foreign_key_constraint_on: author_id
name: author
source: default
comment:
table:
schema: public
name: article
reason: 'Inconsistent object: table "author" is not tracked'
name: object_relation author in table article in source default
type: object_relation
query:
type: replace_metadata
version: 2
@ -27,43 +29,43 @@ query:
allow_inconsistent_metadata: true
metadata:
remote_schemas:
- name: test
comment: testing replace metadata with remote schemas
definition:
url: http://localhost:5000/hello-graphql
forward_client_headers: false
tables:
- table: foobar
object_relationships: []
array_relationships:
- using:
foreign_key_constraint_on:
column: author_id
table: article
name: articles
comment: List all articles of the author
insert_permissions: []
select_permissions: []
update_permissions: []
delete_permissions: []
event_triggers: []
computed_fields:
- name: get_articles
comment: null
- name: test
comment: testing replace metadata with remote schemas
definition:
function: fetch_articles
table_argument: author_row
- table: article
object_relationships:
- using:
foreign_key_constraint_on: author_id
name: author
comment: null
array_relationships: []
insert_permissions: []
select_permissions: []
update_permissions: []
delete_permissions: []
event_triggers: []
url: http://localhost:5000/hello-graphql
forward_client_headers: false
tables:
- table: foobar
object_relationships: []
array_relationships:
- using:
foreign_key_constraint_on:
column: author_id
table: article
name: articles
comment: List all articles of the author
insert_permissions: []
select_permissions: []
update_permissions: []
delete_permissions: []
event_triggers: []
computed_fields:
- name: get_articles
comment: null
definition:
function: fetch_articles
table_argument: author_row
- table: article
object_relationships:
- using:
foreign_key_constraint_on: author_id
name: author
comment: null
array_relationships: []
insert_permissions: []
select_permissions: []
update_permissions: []
delete_permissions: []
event_triggers: []
functions:
- search_articles
- search_articles

View File

@ -3,26 +3,29 @@ url: /v1/query
status: 400
response:
internal:
- definition:
using:
foreign_key_constraint_on:
column: published_on
table:
schema: public
name: article
name: articles
source: default
comment:
table:
schema: public
name: author
reason: 'in table "author": in relationship "articles": no foreign constraint
exists on the given column'
type: array_relation
- definition:
using:
foreign_key_constraint_on:
column: published_on
table:
schema: public
name: article
name: articles
source: default
comment:
table:
schema: public
name: author
reason:
'Inconsistent object: in table "author": in relationship "articles": no
foreign constraint exists on the given column'
name: array_relation articles in table author in source default
type: array_relation
path: $.args
error: 'in table "author": in relationship "articles": no foreign constraint exists
on the given column'
code: constraint-violation
error:
'Inconsistent object: in table "author": in relationship "articles": no foreign
constraint exists on the given column'
code: invalid-configuration
query:
type: create_array_relationship
args:

View File

@ -3,22 +3,25 @@ url: /v1/query
status: 400
response:
internal:
- definition:
using:
foreign_key_constraint_on: published_on
name: author
source: default
comment:
table:
schema: public
name: article
reason: 'in table "article": in relationship "author": no foreign constraint exists
on the given column'
type: object_relation
- definition:
using:
foreign_key_constraint_on: published_on
name: author
source: default
comment:
table:
schema: public
name: article
reason:
'Inconsistent object: in table "article": in relationship "author": no
foreign constraint exists on the given column'
name: object_relation author in table article in source default
type: object_relation
path: $.args
error: 'in table "article": in relationship "author": no foreign constraint exists
on the given column'
code: constraint-violation
error:
'Inconsistent object: in table "article": in relationship "author": no foreign
constraint exists on the given column'
code: invalid-configuration
query:
type: create_object_relationship
args:

View File

@ -3,22 +3,24 @@ url: /v1/query
status: 400
response:
internal:
- definition:
using:
foreign_key_constraint_on:
column: author_id
table:
schema: public
name: article
name: articles
source: default
comment:
table:
schema: public
name: author
reason: field definition conflicts with custom field name for postgres column
"name"
type: array_relation
- definition:
using:
foreign_key_constraint_on:
column: author_id
table:
schema: public
name: article
name: articles
source: default
comment:
table:
schema: public
name: author
reason:
'Inconsistent object: field definition conflicts with custom field name
for postgres column "name"'
name: array_relation articles in table author in source default
type: array_relation
path: $.args
error: cannot continue due to new inconsistent metadata
code: unexpected

View File

@ -3,25 +3,29 @@ url: /v1/query
status: 400
response:
internal:
- definition:
using:
foreign_key_constraint_on:
column: author_id
table:
schema: public
name: article
name: AuthorId
source: default
comment:
table:
schema: public
name: author
reason: field definition conflicts with custom field name for postgres column
"id"
type: array_relation
- definition:
using:
foreign_key_constraint_on:
column: author_id
table:
schema: public
name: article
name: AuthorId
source: default
comment:
table:
schema: public
name: author
reason:
'Inconsistent object: field definition conflicts with custom field name
for postgres column "id"'
name: array_relation AuthorId in table author in source default
type: array_relation
path: $.args
error: field definition conflicts with custom field name for postgres column "id"
code: constraint-violation
error:
'Inconsistent object: field definition conflicts with custom field name for
postgres column "id"'
code: invalid-configuration
query:
type: create_array_relationship
args:

View File

@ -3,22 +3,24 @@ url: /v1/query
status: 400
response:
internal:
- definition:
using:
foreign_key_constraint_on:
column: author_id
table:
schema: public
name: article
name: articles
source: default
comment:
table:
schema: public
name: author
reason: field definition conflicts with custom field name for postgres column
"name"
type: array_relation
- definition:
using:
foreign_key_constraint_on:
column: author_id
table:
schema: public
name: article
name: articles
source: default
comment:
table:
schema: public
name: author
reason:
'Inconsistent object: field definition conflicts with custom field name
for postgres column "name"'
name: array_relation articles in table author in source default
type: array_relation
path: $.args
error: cannot continue due to new inconsistent metadata
code: unexpected

View File

@ -3,25 +3,29 @@ url: /v1/query
status: 400
response:
internal:
- definition:
using:
foreign_key_constraint_on:
column: author_id
table:
schema: public
name: article
name: AuthorId
source: default
comment:
table:
schema: public
name: author
reason: field definition conflicts with custom field name for postgres column
"id"
type: array_relation
- definition:
using:
foreign_key_constraint_on:
column: author_id
table:
schema: public
name: article
name: AuthorId
source: default
comment:
table:
schema: public
name: author
reason:
'Inconsistent object: field definition conflicts with custom field name
for postgres column "id"'
name: array_relation AuthorId in table author in source default
type: array_relation
path: $.args
error: field definition conflicts with custom field name for postgres column "id"
code: constraint-violation
error:
'Inconsistent object: field definition conflicts with custom field name for
postgres column "id"'
code: invalid-configuration
query:
type: create_array_relationship
args:

View File

@ -6,17 +6,20 @@ response:
- definition:
schema: public
name: employees
reason: "the table \"employees\" cannot be used as an enum for the following reasons:\n\
\ • the tables primary key (\"id\") must have type \"text\", not type \"integer\"\
\n • the table must have exactly one primary key and optionally one comment\
\ column, not 4 columns (favorite_color, gets_paid_on, id, name)\n"
reason: "Inconsistent object: the table \"employees\" cannot be used as an enum\
\ for the following reasons:\n • the tables primary key (\"id\") must have\
\ type \"text\", not type \"integer\"\n • the table must have exactly one primary\
\ key and optionally one comment column, not 4 columns (favorite_color, gets_paid_on,\
\ id, name)\n"
name: table employees in source default
type: table
path: $.args
error: "the table \"employees\" cannot be used as an enum for the following reasons:\n\
\ • the tables primary key (\"id\") must have type \"text\", not type \"integer\"\
\n • the table must have exactly one primary key and optionally one comment column,\
\ not 4 columns (favorite_color, gets_paid_on, id, name)\n"
code: constraint-violation
error: "Inconsistent object: the table \"employees\" cannot be used as an enum for\
\ the following reasons:\n • the tables primary key (\"id\") must have type\
\ \"text\", not type \"integer\"\n • the table must have exactly one primary\
\ key and optionally one comment column, not 4 columns (favorite_color, gets_paid_on,\
\ id, name)\n"
code: invalid-configuration
query:
type: set_table_is_enum
args:

View File

@ -35,8 +35,9 @@
- definition:
schema: public
name: colors
reason: the table "colors" cannot be used as an enum because the value
"illegal+graphql+identifier" is not a valid GraphQL enum value name
reason: 'Inconsistent object: the table "colors" cannot be used as an enum because
the value "illegal+graphql+identifier" is not a valid GraphQL enum value name'
name: table colors in source default
type: table
- definition:
using:
@ -47,7 +48,8 @@
table:
schema: public
name: employees
reason: table "colors" is not tracked
reason: 'Inconsistent object: table "colors" is not tracked'
name: object_relation favorite_color_object in table employees in source default
type: object_relation
query:
type: get_inconsistent_metadata

View File

@ -223,7 +223,7 @@ class TestAddRemoteSchemaTbls:
q = mk_add_remote_q('simple2', 'http://localhost:5000/hello-graphql')
st_code, resp = hge_ctx.v1q(q)
assert st_code == 400
assert resp['code'] == 'constraint-violation'
assert resp['code'] == 'invalid-configuration'
@pytest.mark.allow_server_upgrade_test
def test_add_second_remote_schema(self, hge_ctx):