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

Merge plugin generates identical const variables more than once #905

Open
qbunt opened this issue May 13, 2024 · 1 comment
Open

Merge plugin generates identical const variables more than once #905

qbunt opened this issue May 13, 2024 · 1 comment

Comments

@qbunt
Copy link

qbunt commented May 13, 2024

Expected Behavior

  • When running a merge export plugin CLI command, the script generated should not have any const values more than once, especially naming them the same thing as doing so would be a basic violation of the JS runtime.

Actual Behavior

When running the CLI with the merge plugin, as below

yarn dlx contentful space migration --space-id [redacted] --environment-id master stage-master.cjs

The generated migration script contains multiple variables that are named the same thing and immediately fail in a scripted deployment, as they are a syntax error.

Possible Solution

Before writing the file to disk, check all const variables for uniqueness across the script.

Steps to Reproduce

  1. Generate a simple content model that contains a model with a name like toolLanguage
  2. Generate another simple model that's named language for instance
  3. Generate a third simple model that's named tool and make a reference relationship between tool and language called toolLanguage
  4. Generate a migration script from that environment into a new environment
  5. See constant variable name clashing

Context

We attempted to generate a migration script that had closely related naming values and the generated script had multiple conflicting constant names. As this could be running in a headless environment, this should be strictly guarded against. This occurred, in our case, inside a Github action run.

Environment

  • Node v20
  • Yarn v4.1.1
  • Ubuntu-22.04
  • Github Action worker v2.316.1
@qbunt qbunt changed the title Merge plugin generates const values more than once Merge plugin generates identical const values more than once May 15, 2024
@qbunt qbunt changed the title Merge plugin generates identical const values more than once Merge plugin generates identical const variables more than once May 15, 2024
@qbunt
Copy link
Author

qbunt commented May 23, 2024

Anyone care to take a look at this? This issue borked a production build, thought that maybe generating syntactically invalid JS would be a bigger deal 🤷

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant