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

gatsby-transformer-remark: Throws an error when constructor is used as a field value #22508

Closed
stephencweiss opened this issue Mar 23, 2020 · 2 comments · Fixed by #22603
Closed
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby

Comments

@stephencweiss
Copy link
Contributor

Description

I use a tag system for my website's blog. I recently wrote a post about instantiating classes using a constructor function -- I added this as a tag to the post and gastsby-node broke.

So too did my graphql query on my tags page.

I think this is likely because of some conversion where the runtime is viewing constructor as a reserved word... though this is the only reserved word I've come across with this behavior.

Steps to reproduce

Minimal Reproduction:

Expected result

I should be able to have a tag of any valid string and not run into the situation where it breaks the build of my site.

Actual result

$ yarn build

 ERROR #11321  PLUGIN

"gatsby-node.js" threw an error while running the createPages lifecycle:

(acc[key] || []).concat is not a function

failed createPages - 0.064s

 ERROR #85901  GRAPHQL

There was an error in your GraphQL query:

(acc[key] || []).concat is not a function

   1 | query usersstephencodeblogsrcpagestagsJsx3450235017 {
   2 |   site {
   3 |     siteMetadata {
   4 |       title
   5 |     }
   6 |   }
   7 |   allMarkdownRemark(limit: 2000) {
>  8 |     group(field: frontmatter___tags) {
     |     ^
   9 |       fieldValue
  10 |       totalCount
  11 |     }
  12 |   }
  13 | }
  14 |

File path: /Users/stephen/code/blog/src/pages/tags.jsx
Url path: /tags/
Plugin: none

Environment

  System:
    OS: macOS 10.15.3
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.16.1 - ~/.nvm/versions/node/v12.16.1/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.13.4 - ~/.nvm/versions/node/v12.16.1/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 80.0.3987.149
    Safari: 13.0.5
  npmPackages:
    gatsby: ^2.19.45 => 2.19.45 
    gatsby-source-filesystem: ^2.2.2 => 2.2.2 
    gatsby-transformer-remark: ^2.7.1 => 2.7.1 
@stephencweiss stephencweiss added the type: bug An issue or pull request relating to a bug in Gatsby label Mar 23, 2020
stephencweiss added a commit to stephencweiss/stephencharlesweiss.com that referenced this issue Mar 23, 2020
currently, gatsby-transformer-remark seems to error on the tag of `constructor`

Tracking this in an issue: gatsbyjs/gatsby#22508
@vladar
Copy link
Contributor

vladar commented Mar 27, 2020

The error you see is a runtime GraphQL error with group by frontmatter___tags. If you change grouping to something else - it doesn't break anymore. Still looking into why this happens with frontmatter___tags

@vladar
Copy link
Contributor

vladar commented Mar 27, 2020

Oh, I see what you mean now. Here is what happens:

const a = {}
a[`constructor`] // expected: undefined, got function

Here is a PR with a fix: #22603

@vladar vladar added the status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. label Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants