question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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":{}}

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
rohanrajpalcommented, Nov 14, 2022

The official patch is out in 4.6.1

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

1reaction
rohanrajpalcommented, Nov 9, 2022

Thanks for the prompt reply!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Panicked at 'called `Option::unwrap()` on a `None` value ...
I find this part of the error message obtuse: RUST_BACKTRACE=1 refers to an environment variable. Set the environment variable RUST_BACKTRACE to ...
Read more >
Prisma 4.6.1 Release - GitClear
4.6.0 (released November 8, 2022) ... upsert() with nested selection errors with called Option::unwrap() on a None value in 4.6.0 ...
Read more >
Telegraf 1.24 release notes - InfluxData Documentation
Fix memory leak for plugins using ParserFunc . Unwrap parsers and remove some special handling. processors.parser : Add option to parse tags. Dependency...
Read more >
CHANGES — oslo.db 4.13.5 documentation
utils: fix get_unique_keys() when model has no table attached to it ... Deprecate config option sqlite_db for removal; Catch empty value DBDuplicate errors...
Read more >
Apache Tomcat 8 (8.5.84) - Changelog
Include the name of the current stream state in the error message ... setLocale() as it caused regressions for applications using UTF-8.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found