Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PANIC: JSON target types only accept strings or numbers, found: {"bytes":"05010000000473436170"} in query-engine/connectors/sql-query-connector/src/filter_conversion.rs:542:22 #10836

Closed
ac10n opened this issue Dec 22, 2021 · 4 comments
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. topic: basic error report topic: postgresql
Milestone

Comments

@ac10n
Copy link

ac10n commented Dec 22, 2021

Hi Prisma Team! My Prisma Client just crashed. This is the report:

Versions

Name Version
Node v16.13.0
OS rhel-openssl-1.1.x
Prisma Client 3.7.0
Query Engine 0.1.0
Database postgresql

Logs

s loaded from /home/alireza/work/ecad/repos/tezgraph/.env
prisma:client clientVersion: 3.7.0
prisma:client clientEngineType: library
prisma:client:libraryEngine internalSetup
prisma:client:libraryEngine sending request, this.libraryStarted: false
prisma:client:libraryEngine sending request, this.libraryStarted: false
prisma:client:libraryEngine Search for Query Engine Library in /home/alireza/work/ecad/repos/tezgraph/node_modules/.prisma/client
prisma:client:libraryEngine loadEngine using /home/alireza/work/ecad/repos/tezgraph/node_modules/.prisma/client/libquery_engine-rhel-openssl-1.1.x.so.node
prisma:client:libraryEngine library starting
prisma:client:libraryEngine library already starting, this.libraryStarted: false
prisma:client:libraryEngine library started
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:fetcher Error: Error in domain logic: Conversion from `Json("{\"bytes\":\"0501000000024349\"}")` to `Json` failed.
    at prismaGraphQLToJSError (/home/alireza/work/ecad/repos/tezgraph/node_modules/@prisma/client/runtime/index.js:35963:10)
    at Object.request (/home/alireza/work/ecad/repos/tezgraph/node_modules/@prisma/client/runtime/index.js:36324:17)
    at cb (/home/alireza/work/ecad/repos/tezgraph/node_modules/@prisma/client/runtime/index.js:38658:26)
    at /home/alireza/work/ecad/repos/tezgraph/src/modules/queries-graphql/helpers/prisma-pagination.ts:152:38
    at async Promise.all (index 0)
    at runAndConcatenateQueries (/home/alireza/work/ecad/repos/tezgraph/src/modules/queries-graphql/helpers/prisma-pagination.ts:151:22)
    at sortPaginateAndRunQuery (/home/alireza/work/ecad/repos/tezgraph/src/modules/queries-graphql/helpers/prisma-pagination.ts:54:22)
    at async Promise.all (index 0)
    at BigmapKeyRepository.findManyBigmapKeys (/home/alireza/work/ecad/repos/tezgraph/src/modules/queries-graphql/repositories/bigmap-key.ts:46:61)
    at BigmapResolver.keys (/home/alireza/work/ecad/repos/tezgraph/src/modules/queries-graphql/resolvers/bigmap.ts:153:59)
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true

Client Snippet

  const data = await prisma.bigmap.findMany({
    where: { id: 12 },
    select: { key: true, key_hash: true, id: true },
    orderBy: [{ id: "asc" }, { key: "asc" }],
    take: 11,
    distinct: ["key"],
  });

Schema

model bigmap {
  id                                      BigInt?
  key                                     Json?
  key_hash                                String?          @db.Char(54)
  key_type                                Json?
  value                                   Json?
  value_type                              Json?
  block_hash_id                           Int
  operation_id                            BigInt?
  implicit_operations_results_id          Int?
  sender_id                               BigInt?
  receiver_id                             BigInt?
  i                                       BigInt
  kind                                    Int              @db.SmallInt
  annots                                  String?
  strings                                 String[]
  uri                                     Int[]
  contracts                               BigInt[]
  metadata                                Json?
  block                                   block            @relation(fields: [block_hash_id], references: [hash_id], onDelete: Cascade, onUpdate: NoAction, map: "bigmap_block_hash_block_fkey")
  block_hash                              block_hash       @relation(fields: [block_hash_id], references: [hash_id], onDelete: Cascade, onUpdate: NoAction) // Custom Added
  operation_alpha                         operation_alpha? @relation(fields: [operation_id], references: [autoid], onDelete: Cascade, onUpdate: NoAction)
  addresses_addressesTobigmap_receiver_id addresses?       @relation("addressesTobigmap_receiver_id", fields: [receiver_id], references: [address_id], onDelete: Cascade, onUpdate: NoAction, map: "bigmap_receiver_fkey")
  addresses_addressesTobigmap_sender_id   addresses?       @relation("addressesTobigmap_sender_id", fields: [sender_id], references: [address_id], onDelete: Cascade, onUpdate: NoAction, map: "bigmap_sender_fkey")

  @@id([block_hash_id, i])
  @@index([annots], map: "bigmap_annots")
  @@index([block_hash_id], map: "bigmap_block_hash")
  @@index([contracts], map: "bigmap_contracts")
  @@index([id], map: "bigmap_id")
  @@index([id, annots], map: "bigmap_id_annots")
  @@index([id, block_hash_id], map: "bigmap_id_bhid")
  @@index([id, key_hash, block_hash_id, i], map: "bigmap_id_kh_bhid_i")
  @@index([id, key_hash, i], map: "bigmap_id_kh_i")
  @@index([key], map: "bigmap_key")
  @@index([key_hash], map: "bigmap_key_hash")
  @@index([key_type], map: "bigmap_key_type")
  @@index([metadata], map: "bigmap_metadata")
  @@index([operation_id], map: "bigmap_operation_id")
  @@index([receiver_id], map: "bigmap_receiver")
  @@index([sender_id], map: "bigmap_sender")
  @@index([uri], map: "bigmap_uri")
}

Prisma Engine Query

{"X":{}}

If we remove the distinct field, query will succeed. Same value that previously failed the query now returns successfuly. Same error if I create a view that does the distinct and then query that.
If I check the column type of key in both the original table and the view, both are jsonb.

@janpio janpio added bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug. team/client Issue for team Client. topic: basic error report topic: postgresql labels Dec 22, 2021
@ac10n
Copy link
Author

ac10n commented Dec 23, 2021

Sorry, the provided trace and error message are for a different query. The provided one throws:

thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: ConversionFailure("Json(\"{\\\"bytes\\\":\\\"0501000000024349\\\"}\")", "Json")', query-engine/core/src/interpreter/query_interpreters/inmemory_record_processor.rs:120:26
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
/home/alireza/work/ecad/test/prisma-querying/node_modules/@prisma/client/runtime/index.js:38692
          throw new PrismaClientUnknownRequestError(message, this.prisma._clientVersion);
                ^
PrismaClientUnknownRequestError: 
Invalid `prisma.bigmap.findMany()` invocation in
/home/alireza/work/ecad/test/prisma-querying/index.ts:6:36

  3 const prisma = new PrismaClient();
  4 
  5 async function main() {
→ 6   const data = await prisma.bigmap.findMany(
  called `Result::unwrap()` on an `Err` value: ConversionFailure("Json(\"{\\\"bytes\\\":\\\"0501000000024349\\\"}\")", "Json")
    at cb (/home/alireza/work/ecad/test/prisma-querying/node_modules/@prisma/client/runtime/index.js:38692:17) {
  clientVersion: '3.7.0'

I'll try to provide a reproduction for the original error as well.

@etino
Copy link

etino commented Mar 8, 2022

I'm having the same problem with a findMany query with distict.

thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: 
ConversionFailure("Float(BigDecimal(\"100\"))", "Decimal")', 
query-engine\core\src\interpreter\query_interpreters\inmemory_record_processor.rs:120:26
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

The issue occurs when I add in the distinct definition a field with Decimal type (of different from string
In my case referenceQty is defined as Decimal in schema.prisma.
Removing this field, it works.

      const recipes = await prisma.importedRecipeBom.findMany({
        select: {
          code: true, 
          description: true,
          um: true,
          referenceQty: true, // Field defined as   recipeReferenceQty     Decimal?
        },
        where: {
          NOT: {
            recipeCode: null
          }
        },
        distinct: [
          'code', 
          'description', 
          'um', 
          'referenceQty',    // Decimal Field
      })

@janpio
Copy link
Member

janpio commented Mar 10, 2022

Your problem looks different by the file where the error is happening @etino. Can you please open a new issue and provide more information? Thanks.

@pantharshit00 pantharshit00 added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. and removed bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. labels Jun 2, 2022
@cprieto
Copy link

cprieto commented Jun 21, 2022

This is pretty much the same as #7891 and it is now closed by prisma/prisma-engines#2985.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. topic: basic error report topic: postgresql
Projects
None yet
Development

No branches or pull requests

5 participants