Generate scaffold error

Hey everyone, was recently trying to generate a new scaffold and come across this strange error:

  ✖ Generating scaffold files...
    →   38 |   scenario('deletes a group', async (scenario) => {
                 Adding scaffold routes...
                 Adding scaffold asset imports...
                 Unexpected token, expected "]" (35:27)
        33 | 
        34 |     
      > 35 |     expect(result.[object Object]).toEqual("[object Object]")
           |                          ^
        36 |   })
        37 | 
        38 |   scenario('deletes a group', async (scenario) => {
   Done in 4.03s.

Any idea what could be causing this?

I’ve had this one.

Can you share your schema.prisma and the appropriate *.scenario.js ?

As I recall it’s due to model relations.

Hey, yeah this is the relevant code in prisma.schema

model Group {
  id     Int    @id @default(autoincrement())
  user   User   @relation(fields: [userId], references: [id])
  userId Int
  name   String
  slug   String

I don’t have any *.scenario.js file, because the generator fails before any of the files are generated

I should also say that the only actions I took before this error appeared were:

  1. adding that code to schema.prisma
  2. running yarn rw prisma migrate dev

Hmmmmmmmmm it’s possible that an update to Prisma may have changed how they introspect the schema file and report what it contains. We use the output of that introspection to figure out what fields to generate in the scaffold.

That error is in the code that’s generated for the test file for a service. It tests making an update to a field and then checking that the update actually occurred in the database. What should have been a string from the prisma introspection is now an object instead, and that’s what’s being output in the generated file.

I’ve opened an issue here:

@undertow could you let us know which version of Redwood your using? Also, to double-check, I’d like to confirm which version of Prisma you’re using — if you ever manually installed Prisma in your project, things might be out of sync.

Please copy + paste the output from the following two commands:

  1. yarn prisma --version
  2. yarn rw info

Thanks in advance!

@rob @thedavid Thanks for the reply guys, here’s the prisma and rw info:

prisma               : 2.18.0
@prisma/client       : 2.18.0
Current platform     : debian-openssl-1.1.x
Query Engine         : query-engine da6fafb57b24e0b61ca20960c64e2d41f9e8cff1 (at node_modules/@prisma/engines/query-engine-debian-openssl-1.1.x)
Migration Engine     : migration-engine-cli da6fafb57b24e0b61ca20960c64e2d41f9e8cff1 (at node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine : introspection-core da6fafb57b24e0b61ca20960c64e2d41f9e8cff1 (at node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary        : prisma-fmt da6fafb57b24e0b61ca20960c64e2d41f9e8cff1 (at node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Studio               : 0.356.0

    OS: Linux 5.8 Pop!_OS 20.10
    Shell: 5.8 - /usr/bin/zsh
    Node: 14.14.0 - /tmp/yarn--1616432149925-0.679766484840328/node
    Yarn: 1.22.5 - /tmp/yarn--1616432149925-0.679766484840328/yarn
    SQLite: 3.33.0 - /usr/bin/sqlite3
    Firefox: 86.0
    @redwoodjs/core: ^0.27.1 => 0.27.1

Edit: By the way, the generators were working fine before I upgraded from v25 to v27, so it’s possible that I messed up somewhere along the way while upgrading

I just pushed a fix for this so whenever 0.28 is released you should be good to go @undertow!


Thanks @undertow That all looks good and correct.

Will coordinate with @rob to get this fix into v0.28, which should be out this week.

@rob @thedavid Fantastic guys, looking forward to the next release!

@undertow Curious if the v28 release fixed your scaffolding error?

@dthyresson I was literally doing the upgrade as you wrote that :grin:
Once it’s done I’ll generate something and let you know

1 Like

@dthyresson All working! Thanks for the quick update :+1:


Thanks for reporting and confirmed so fast as well! Cheers.

1 Like