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

upsert() with nested selection errors with called Option::unwrap() on a None value in 4.6.0 #16196

Closed
rohanrajpal opened this issue Nov 9, 2022 · 7 comments · Fixed by prisma/prisma-engines#3377
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. topic: upsert nested upsert
Milestone

Comments

@rohanrajpal
Copy link

rohanrajpal commented Nov 9, 2022

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

Versions

Name Version
Node v16.18.1
OS debian-openssl-3.0.x
Prisma Client 4.6.0
Query Engine 2e719efb80b56a3f32d18a62489de95bb9c130e3
Database postgresql

Logs

raryStarted: 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: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 prisma.queryRaw(
            SELECT count(*) contacts,sum(O.amount) revenue,count(O) orders,count(CD.id) collaborations,count(CQ.id) queries, count(C."followedFromNudge") followers
              from "Contact" C
              LEFT JOIN "Order" O on C.id = O."contactId"
              LEFT JOIN "CollaborationDetail" CD on C.id = CD."contactId"
              LEFT JOIN "CustomerQuery" CQ on C.id = CQ."contactId"
            where C."userProfileId" = $1
            , [91])
prisma:client Prisma Client call:
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

return this.prisma.shopifyStore.upsert({
            where: { shopUrl },
            create: {
                name: shop.name,
                adminGraphqlId: shop.id,
                shopifyPlus: shop.plan.shopifyPlus,
                description: shop.description,
                contactEmail: shop.contactEmail,
                shopUrl,
                email: shop.email,
                planName: shop.plan.displayName,
                partnerDevelopmentPlan: shop.plan.partnerDevelopment,
                primaryDomainUrl: shop.primaryDomain.url.replace('https://', ''),
                currencyCode: shop.currencyCode,
                ianaTimeZone: shop.ianaTimezone,
                orderNumberFormatPrefix: shop.orderNumberFormatPrefix,
                orderNumberFormatSuffix: shop.orderNumberFormatSuffix,
                features: shop.features,
                // shopPolicies: shop.shopPolicies,
                accessToken,
            },
            update: {
                name: shop.name,
                adminGraphqlId: shop.id,
                shopifyPlus: shop.plan.shopifyPlus,
                description: shop.description,
                contactEmail: shop.contactEmail,
                email: shop.email,
                planName: shop.plan.displayName,
                partnerDevelopmentPlan: shop.plan.partnerDevelopment,
                primaryDomainUrl: shop.primaryDomain.url.replace('https://', ''),
                currencyCode: shop.currencyCode,
                ianaTimeZone: shop.ianaTimezone,
                orderNumberFormatPrefix: shop.orderNumberFormatPrefix,
                orderNumberFormatSuffix: shop.orderNumberFormatSuffix,
                features: shop.features,
                // shopPolicies: shop.shopPolicies,
                accessToken,
            },
            select: {
                email: true,
                id: true,
                userProfile: { select: { id: true, user: { select: { id: true, email: true } } } },
            },
        });

Schema

model ShopifyStore {
  id                      Int      @id @default(autoincrement())
  adminGraphqlId          String?  @unique
  createdAt               DateTime @default(now())
  updatedAt               DateTime @updatedAt
  accessToken             String?
  storefrontAccessToken   String?
  currencyCode            String?
  ianaTimeZone            String?
  orderNumberFormatPrefix String?
  orderNumberFormatSuffix String?
  features                Json?
  shopPolicies            Json[]
  name                    String?
  email                   String?
  contactEmail            String?
  planName                String?
  partnerDevelopmentPlan  Boolean?
  shopifyPlus             Boolean?
  description             String?
  primaryDomainUrl        String?  @unique
  scriptTagInfo           Json?
  webhookIDs              String[]
  shopUrl                 String   @unique

  spurPlan             SpurPlan   @default(FREE)
  subId                String?    @unique
  subName              String?
  subCreatedAt         DateTime?
  subUpdatedAt         DateTime?
  subStatus            SubStatus?
  subTest              Boolean?
  subCurrentPeriodEnd  DateTime?
  subRecurringId       String?
  subRecurringPrice    Int?
  subUsageId           String?
  subUsageCappedAmount Decimal?
  subUsageBalanceUsed  Decimal?
  subConfirmationUrl   String?

  numContactsBilled Int      @default(0)
  monthStartedAt    DateTime @default(now())

  userProfile UserProfile?
}

enum SpurPlan {
  FREE
  STARTER
  GROWTH
}

Prisma Engine Query

{"X":{}}
@SevInf SevInf added 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: upsert nested upsert labels Nov 9, 2022
@Jolg42 Jolg42 added this to the 4.7.0 milestone Nov 9, 2022
@Jolg42 Jolg42 added bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Nov 9, 2022
@Jolg42
Copy link
Member

Jolg42 commented Nov 9, 2022

Hi @rohanrajpal !
Thanks for the issue, we are looking into this.
We will prepare a patch release tomorrow.
We'll keep you updated as soon as it's available.

@Jolg42 Jolg42 changed the title called Option::unwrap() on a None value upset() with nested selection errors with called Option::unwrap() on a None value in 4.6.0 Nov 9, 2022
@Jolg42 Jolg42 changed the title upset() with nested selection errors with called Option::unwrap() on a None value in 4.6.0 upsert() with nested selection errors with called Option::unwrap() on a None value in 4.6.0 Nov 9, 2022
@rohanrajpal
Copy link
Author

Thanks for the prompt reply!

@Jolg42
Copy link
Member

Jolg42 commented Nov 10, 2022

@rohanrajpal Could you try to update prisma and @prisma/client to the 4.6.1-dev.2 internal patch version that includes the fixes and let us know if that solves your issue?

We will proceed with an official patch later today.

@rohanrajpal
Copy link
Author

rohanrajpal commented Nov 10, 2022

@rohanrajpal Could you try to update prisma and @prisma/client to the 4.6.1-dev.2 internal patch version that includes the fixes and let us know if that solves your issue?

We will proceed with an official patch later today.

Would it be okay if I try it out by Saturday and let you know? A little occupied till this Friday evening.

@Jolg42
Copy link
Member

Jolg42 commented Nov 10, 2022

@rohanrajpal We are planning to release the official 4.6.1 patch today as we have other fixes that we want to include.
I'll keep you updated when it's available, and then if you can confirm if it solves your issue when you have some time 👍🏼

@Jolg42
Copy link
Member

Jolg42 commented Nov 10, 2022

The official patch is out in 4.6.1

@rohanrajpal
Copy link
Author

The official patch is out in 4.6.1

Hey, sorry it took me a while but all is working well now!

@garrensmith garrensmith removed their assignment Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. topic: upsert nested upsert
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants