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: called Result::unwrap() on an Err value: FieldNotFound { name: "upsert", model: "CcStructureUnit" } in query-engine/core/src/query_graph_builder/write/write_args_parser.rs:24:62 #10636

Closed
terion-name opened this issue Dec 9, 2021 · 1 comment · Fixed by prisma/prisma-engines#2981
Assignees
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: mysql
Milestone

Comments

@terion-name
Copy link

TLDR: Panic instead of proper error that is present in log (The records for relation ActSession between the Session and Act models are not connected)

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

Versions

Name Version
Node v16.12.0
OS debian-openssl-1.1.x
Prisma Client 3.6.0
Query Engine 0.1.0
Database mysql

Logs

e records that were required but not found. Record to update not found.
    at prismaGraphQLToJSError (/builds/iiZRJCEG/0/dobre/dosvit/infrastructure/ci/application-build/app/.dosvit/context/test/prisma/runtime/index.js:35956:12)
    at Object.request (/builds/iiZRJCEG/0/dobre/dosvit/infrastructure/ci/application-build/app/.dosvit/context/test/prisma/runtime/index.js:36319:17)
    at async cb (/builds/iiZRJCEG/0/dobre/dosvit/infrastructure/ci/application-build/app/.dosvit/context/test/prisma/runtime/index.js:38653:26)
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:fetcher Error: The records for relation `ActSession` between the `Session` and `Act` models are not connected.
    at prismaGraphQLToJSError (/builds/iiZRJCEG/0/dobre/dosvit/infrastructure/ci/application-build/app/.dosvit/context/test/prisma/runtime/index.js:35956:12)
    at Object.request (/builds/iiZRJCEG/0/dobre/dosvit/infrastructure/ci/application-build/app/.dosvit/context/test/prisma/runtime/index.js:36319:17)
    at async cb (/builds/iiZRJCEG/0/dobre/dosvit/infrastructure/ci/application-build/app/.dosvit/context/test/prisma/runtime/index.js:38653:26)
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:fetcher Error: Foreign key constraint failed on the field: `absentId`
    at prismaGraphQLToJSError (/builds/iiZRJCEG/0/dobre/dosvit/infrastructure/ci/application-build/app/.dosvit/context/test/prisma/runtime/index.js:35956:12)
    at Object.request (/builds/iiZRJCEG/0/dobre/dosvit/infrastructure/ci/application-build/app/.dosvit/context/test/prisma/runtime/index.js:36319:17)
    at async cb (/builds/iiZRJCEG/0/dobre/dosvit/infrastructure/ci/application-build/app/.dosvit/context/test/prisma/runtime/index.js:38653:26)
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:fetcher Error: An operation failed because it depends on one or more records that were required but not found. No 'Session' record (needed to inline the relation on 'Act' record) was found for a nested createMany on relation 'ActSession'.
    at prismaGraphQLToJSError (/builds/iiZRJCEG/0/dobre/dosvit/infrastructure/ci/application-build/app/.dosvit/context/test/prisma/runtime/index.js:35956:12)
    at Object.request (/builds/iiZRJCEG/0/dobre/dosvit/infrastructure/ci/application-build/app/.dosvit/context/test/prisma/runtime/index.js:36319:17)
    at async cb (/builds/iiZRJCEG/0/dobre/dosvit/infrastructure/ci/application-build/app/.dosvit/context/test/prisma/runtime/index.js:38653:26)
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:fetcher Error: An operation failed because it depends on one or more records that were required but not found. No 'Session' record (needed to update inlined relation on 'Session') was found for a nested upsert on relation 'SessionResponsible'.
    at prismaGraphQLToJSError (/builds/iiZRJCEG/0/dobre/dosvit/infrastructure/ci/application-build/app/.dosvit/context/test/prisma/runtime/index.js:35956:12)
    at Object.request (/builds/iiZRJCEG/0/dobre/dosvit/infrastructure/ci/application-build/app/.dosvit/context/test/prisma/runtime/index.js:36319:17)
    at async cb (/builds/iiZRJCEG/0/dobre/dosvit/infrastructure/ci/application-build/app/.dosvit/context/test/prisma/runtime/index.js:38653:26)
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true

Client Snippet

prisma.session.update({
  "where": {
    "id": "ckwz1qt3y006kka922r0chyhz"
  },
  "data": {
    "sessionDate": "2021-12-09T07:56:08Z",
    "updatedAt": "2021-12-08T22:19:14Z",
    "session": {
      "disconnect": false
    },
    "type": {
      "update": {
        "name": "Пані Славута Павленко",
        "status": "ACTIVE",
        "updatedAt": "2021-12-08T21:37:42Z"
      }
    },
    "acts": {
      "updateMany": [
        {
          "where": {
            "id": {
              "lt": "ckwz1qt3y006mka92f8aa5l30"
            },
            "sessionId": {
              "endsWith": "jua;^IbE]="
            }
          },
          "data": {
            "sessionId": "<U9)3T*N<Y"
          }
        }
      ]
    },
    "protocols": {
      "disconnect": [
        {
          "id": "ckwz1qt3y006lka92evnq9669"
        }
      ]
    },
    "absent": {
      "updateMany": [
        {
          "where": {
            "id": {
              "in": [
                "ckwz1qt3z006nka92f62hcgjx"
              ]
            },
            "entityId": {
              "lte": "rjvt\"rOn<q"
            },
            "absentId": {
              "gte": ">Ih_{Vu;+a"
            }
          },
          "data": {
            "upsert": [
              {
                "where": {
                  "id": "ckwz1qt3z006oka923m3hagz3"
                },
                "update": {
                  "updatedAt": "2021-12-08T21:32:21Z"
                },
                "create": {
                  "id": "ckwz1qt3z006qka926tpe4rwu"
                }
              }
            ]
          }
        }
      ]
    }
  },
  "select": {
    "id": true,
    "sessionId": true,
    "typeId": true,
    "sessionDate": true,
    "responsibleId": true,
    "createdAt": true,
    "updatedAt": true
  }
})

Schema

model Act {
  id String @id @default(cuid())

  session Session @relation(name: "ActSession", fields: [sessionId], references: [id])
  sessionId String

  document DocumentsDocument @relation(name: "ActDocumentsDocument", fields: [docId], references: [id])
  docId String

  accepted Boolean @default(false)
  isManual Boolean @default(false)

  votes Vote[] @relation(name:"VoteAct")

  createdAt DateTime @default(now())
  updatedAt DateTime @default(now())
}
model CcStructureUnit {
  id String  @unique
  entityId String @id @default(cuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @default(now())

  sessions Session[] @relation(name: "SessionResponsible")
  deputies Vote[] @relation(name: "VoteDeputy")

  absent Session? @relation(name: "SessionAbsent", fields: [absentId], references: [id])
  absentId String?
}
model DocumentsDocument {
    id String  @unique
    entityId String @id @default(cuid())
    createdAt DateTime   @default(now())
    updatedAt DateTime    @updatedAt

    acts Act[] @relation(name: "ActDocumentsDocument")

    session Session? @relation(name: "SessionProtocols", fields: [sessionId], references: [id])
    sessionId String?
}
model DocumentsSession {
  id String  @unique
  entityId String @id @default(cuid())
  createdAt DateTime   @default(now())
  updatedAt DateTime    @updatedAt

  sessions Session[]     @relation(name: "SessionToDocumentsSession")
}
model Session {
  id String @id @default(cuid())

  session DocumentsSession? @relation(name: "SessionToDocumentsSession", fields: [sessionId], references: [id])
  sessionId String?

  type Type @relation(name: "SessionType", fields: [typeId], references: [id])
  typeId String

  sessionDate DateTime

  acts Act[]     @relation(name: "ActSession")

  protocols DocumentsDocument[] @relation(name: "SessionProtocols")
  responsible CcStructureUnit? @relation(name: "SessionResponsible", fields: [responsibleId], references: [id])
  responsibleId String?

  absent CcStructureUnit[] @relation(name: "SessionAbsent")

  createdAt DateTime @default(now())
  updatedAt DateTime @default(now())
}
model Type {
  id String @id @default(cuid())

  name String
  title String
  status TypeStatus @default(INACTIVE)

  sessions Session[]      @relation(name: "SessionType")

  createdAt DateTime @default(now())
  updatedAt DateTime @default(now())
}
enum TypeStatus {
  ACTIVE
  INACTIVE
}
model Vote {
  id String @id @default(cuid())

  act Act @relation(name: "VoteAct", fields: [actId], references: [id])
  actId String

  deputy CcStructureUnit @relation(name: "VoteDeputy", fields: [deputyId], references: [id])
  deputyId String

  type VoteType

  createdAt DateTime @default(now())
  updatedAt DateTime @default(now())
}
enum VoteType {
  FOR
  AGAINST
  ABSTAINED
  DID_NOT_VOTE
}

PS
DB structure is ok, all tables and fields in place. Underlying error is also ok, but instead of showing it, engine throws panic

@janpio janpio added topic: basic error report bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. topic: mysql team/client Issue for team Client. labels Dec 17, 2021
@Weakky Weakky self-assigned this Jun 15, 2022
@janpio janpio added this to the 4.0.x milestone Jun 16, 2022
@Weakky
Copy link
Member

Weakky commented Jun 17, 2022

Hey,

This was fixed by prisma/prisma-engines#2981 and should be available in the next release.

Thanks for reporting 🙏

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: mysql
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants