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

Comments Break Parsing Logic #57

Open
ddhorstman opened this issue Feb 18, 2022 · 2 comments
Open

Comments Break Parsing Logic #57

ddhorstman opened this issue Feb 18, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@ddhorstman
Copy link

ddhorstman commented Feb 18, 2022

Describe the bug
It would seem that the presence of comments in my files is confusing aurora. In my org, we like to use comments as dividers to make our files easier to navigate, like so:

//--------------------------------------------------------------------------------------------------//

But the presence of a single //- sequence causes aurora to crash.

To Reproduce

  1. Install aurora.
  2. Pick the Author and Book schemas from README.md, and set up aurora.config.json` to combine them.
  3. Add //- anywhere in either file.
  4. Run aurora

Expected behavior
The two schemas are combined into a single schema

Actual Behavior
The following error is printed:

    / \     _   _   _ __    ___    _ __    __ _ 
   / _ \   | | | | | '__|  / _ \  | '__|  / _` |
  / ___ \  | |_| | | |    | (_) | | |    | (_| |
 /_/   \_\  \__,_| |_|     \___/  |_|     \__,_|
                                                
TypeError: Cannot read properties of undefined (reading 'filter')
    at /home/davidhorstman/GitHub/clipboard-staffing-api/node_modules/prisma-aurora/lib/helpers/parseSchema.js:103:84
    at Array.map (<anonymous>)
    at /home/davidhorstman/GitHub/clipboard-staffing-api/node_modules/prisma-aurora/lib/helpers/parseSchema.js:102:59
    at step (/home/davidhorstman/GitHub/clipboard-staffing-api/node_modules/prisma-aurora/lib/helpers/parseSchema.js:44:23)
    at Object.next (/home/davidhorstman/GitHub/clipboard-staffing-api/node_modules/prisma-aurora/lib/helpers/parseSchema.js:25:53)
    at fulfilled (/home/davidhorstman/GitHub/clipboard-staffing-api/node_modules/prisma-aurora/lib/helpers/parseSchema.js:16:58) Aurora could not parse the schema at ./src/modules/workers/worker-model.prisma. Please ensure it is of a proper format.
/home/davidhorstman/GitHub/clipboard-staffing-api/node_modules/prisma-aurora/lib/helpers/parseSchema.js:103
                                model.extendedFields = attributeData_1[model.name].filter(function (attribute) { return attribute.isFieldAttribute; });
                                                                                   ^

TypeError: Cannot read properties of undefined (reading 'filter')
    at /home/davidhorstman/GitHub/clipboard-staffing-api/node_modules/prisma-aurora/lib/helpers/parseSchema.js:103:84
    at Array.map (<anonymous>)
    at /home/davidhorstman/GitHub/clipboard-staffing-api/node_modules/prisma-aurora/lib/helpers/parseSchema.js:102:59
    at step (/home/davidhorstman/GitHub/clipboard-staffing-api/node_modules/prisma-aurora/lib/helpers/parseSchema.js:44:23)
    at Object.next (/home/davidhorstman/GitHub/clipboard-staffing-api/node_modules/prisma-aurora/lib/helpers/parseSchema.js:25:53)
    at fulfilled (/home/davidhorstman/GitHub/clipboard-staffing-api/node_modules/prisma-aurora/lib/helpers/parseSchema.js:16:58)

Desktop (please complete the following information):

  • OS: Windows 10, WSL2 (Ubuntu 20.04)

Screenshots
image

@ddhorstman ddhorstman changed the title TypeError: Cannot read properties of undefined (reading 'filter') Comments Break Parsing Logic Feb 18, 2022
@sabinadams
Copy link
Owner

I can't seem to recreate this issue. Can you paste in the schema you are using?

@cmd-johnson
Copy link

I'm encountering that same issue. It occurs every time I'm using comments before defining a model:

  • Works:

    model ModelA {
      // Comment
      id Int @id
    }
  • Fails:

    // Comment
    model ModelA {
      id Int @id
    }

Both using Aurora 1.3.3 running with node v16.13.0 on linux, with the following config:

{
  "files": [
    "./modelA.prisma"
  ],
  "output": "./schema.prisma"
}
Error Output
TypeError: Cannot read properties of undefined (reading 'filter')
    at /tmp/xfs-9f75d524/dlx-74100/node_modules/prisma-aurora/lib/helpers/parseSchema.js:103:84
    at Array.map (<anonymous>)
    at /tmp/xfs-9f75d524/dlx-74100/node_modules/prisma-aurora/lib/helpers/parseSchema.js:102:59
    at step (/tmp/xfs-9f75d524/dlx-74100/node_modules/prisma-aurora/lib/helpers/parseSchema.js:44:23)
    at Object.next (/tmp/xfs-9f75d524/dlx-74100/node_modules/prisma-aurora/lib/helpers/parseSchema.js:25:53)
    at fulfilled (/tmp/xfs-9f75d524/dlx-74100/node_modules/prisma-aurora/lib/helpers/parseSchema.js:16:58) Aurora could not parse the schema at ./modelA.prisma. Please ensure it is of a proper format.
/tmp/xfs-9f75d524/dlx-74100/node_modules/prisma-aurora/lib/helpers/parseSchema.js:103
                                model.extendedFields = attributeData_1[model.name].filter(function (attribute) { return attribute.isFieldAttribute; });
                                                                                   ^

TypeError: Cannot read properties of undefined (reading 'filter')
    at /tmp/xfs-9f75d524/dlx-74100/node_modules/prisma-aurora/lib/helpers/parseSchema.js:103:84
    at Array.map (<anonymous>)
    at /tmp/xfs-9f75d524/dlx-74100/node_modules/prisma-aurora/lib/helpers/parseSchema.js:102:59
    at step (/tmp/xfs-9f75d524/dlx-74100/node_modules/prisma-aurora/lib/helpers/parseSchema.js:44:23)
    at Object.next (/tmp/xfs-9f75d524/dlx-74100/node_modules/prisma-aurora/lib/helpers/parseSchema.js:25:53)
    at fulfilled (/tmp/xfs-9f75d524/dlx-74100/node_modules/prisma-aurora/lib/helpers/parseSchema.js:16:58)

Comments before datasource, generator and enum definitions work fine:

// Comment
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

// Comment
generator client {
  provider = "prisma-client-js"
}

// Comment
enum TestEnum {
  TEST
}

@sabinadams sabinadams added the bug Something isn't working label Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants