Confusing error when path is omitted from a json filter
See original GitHub issueBug description
When the path
field is omitted from a json filter the following error is returned:
Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState("42883"), message: "operator does not exist: jsonb ~~ unknown", detail: None, hint: Some("No operator matches the given name and argument types. You might need to add explicit type casts."), position: Some(Original(116)), where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("parse_oper.c"), line: Some(722), routine: Some("op_error") }) }) })
How to reproduce
Start the Query Engine with the datamodel provided below and execute the given GraphQL query.
Expected behavior
I would’ve expected an error message similar to the one provided when a field is missing from a createOne
mutation, e.g.
Failed to validate the query: `Unable to match input value to any allowed input type for the field. Parse errors: [Query parsing/validation error at `Mutation.createOnePost.data.PostCreateInput.title`: A value is required but not set., Query parsing/validation error at `Mutation.createOnePost.data.PostUncheckedCreateInput.title`: A value is required but not set.]` at `Mutation.createOnePost.data`
Prisma information
datasource db {
provider = "postgres"
url = env("DATABASE_URL")
}
generator db {
provider = "prisma-client-py"
interface = "asyncio"
recursive_type_depth = -1
previewFeatures = ["filterJson"]
}
model Types {
id String @id @default(cuid())
json_obj Json? @default("{}")
}
GraphQL query:
query {
result: findFirstTypes
(
where: {
json_obj: {
string_contains: "Rott"
}
}
)
{
id
json_obj
}
}
Environment & setup
- OS: Mac OS
- Database: PostgreSQL
- Node.js version: N/A
Prisma Version
prisma : 3.4.0
@prisma/client : Not found
Current platform : darwin
Query Engine (Binary) : query-engine cc47a92cdfc3d0b9210fd4c86f33946a11e4636a (at ../../../../../var/folders/ql/0v8h20s972s6zz4t_3qc49bc0000gp/T/prisma/binaries/engines/cc47a92cdfc3d0b9210fd4c86f33946a11e4636a/prisma-query-engine-darwin, resolved by PRISMA_QUERY_ENGINE_BINARY)
Migration Engine : migration-engine-cli cc47a92cdfc3d0b9210fd4c86f33946a11e4636a (at ../../../../../var/folders/ql/0v8h20s972s6zz4t_3qc49bc0000gp/T/prisma/binaries/engines/cc47a92cdfc3d0b9210fd4c86f33946a11e4636a/prisma-migration-engine-darwin, resolved by PRISMA_MIGRATION_ENGINE_BINARY)
Introspection Engine : introspection-core cc47a92cdfc3d0b9210fd4c86f33946a11e4636a (at ../../../../../var/folders/ql/0v8h20s972s6zz4t_3qc49bc0000gp/T/prisma/binaries/engines/cc47a92cdfc3d0b9210fd4c86f33946a11e4636a/prisma-introspection-engine-darwin, resolved by PRISMA_INTROSPECTION_ENGINE_BINARY)
Format Binary : prisma-fmt cc47a92cdfc3d0b9210fd4c86f33946a11e4636a (at ../../../../../var/folders/ql/0v8h20s972s6zz4t_3qc49bc0000gp/T/prisma/binaries/engines/cc47a92cdfc3d0b9210fd4c86f33946a11e4636a/prisma-prisma-fmt-darwin, resolved by PRISMA_FMT_BINARY)
Default Engines Hash : 1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85
Studio : 0.438.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Karate json path filter not working when trying to extract ...
I am trying to filter my API response using JSON Path filter using ... not able to map variable properly, so my filter...
Read more >Filtering | JSON:API module | Drupal Wiki guide on Drupal.org
First, a warning: don't make the mistake of confusing filters for access control. Just because you've written a filter to remove something that ......
Read more >12.18.3 Functions That Search JSON Values
Returns data from a JSON document, selected from the parts of the document matched by the path arguments. Returns NULL if any argument...
Read more >12: 9.15. JSON Functions and Operators - PostgreSQL
The field/element/path extraction operators return NULL, rather than failing, if the JSON input does not have the right structure to match the request;...
Read more >13: 9.16. JSON Functions and Operators : Postgres Professional
Extracts JSON sub-object at the specified path, where path elements can be ... The jsonpath operators @? and @@ suppress the following errors:...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So, json values can be anything JSON valid. This includes raw strings. If a
path
was always required, we wouldn’t be able to match strings at the root of the JSON blob. Check the following example:For that reason I’m hesitant to consider this a bug, and unless there’s any objection, the existing behavior is correct, and the query should return
null
when the intent of the user is look into the JSON structure, but nofield
is provided in the query.The issue of no data and no error does exist in 4.3.1. Reproduction:
Debug logs: