Skip to content

Merge plugin generates identical const variables more than once #2994

@qbunt

Description

@qbunt

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions