Skip to content

codegen generates inconsistent casing for Enum models in v13.0.1 causing ReferenceError #14223

@Tr1ckyy1

Description

@Tr1ckyy1

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

20.19.2

Amplify CLI Version

13.0.1

What operating system are you using?

Windows

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No manual changes were made. This issue is reproducible after a fresh installation of Amplify CLI v13.0.1 and running amplify codegen models.

Describe the bug

When running amplify codegen models, the generated file at src/models/index.js contains a ReferenceError.

The generator creates JavaScript constants for GraphQL enums with PascalCasing (e.g., const RtcRecordType = { ... }), but the export statement at the end of the file tries to export them using a different, uppercase casing (e.g., export { RTCRecordType }). This causes the application build to fail because the exported identifier does not exist.

This issue started occurring immediately after upgrading from @aws-amplify/cli@13.0.0 to @aws-amplify/cli@13.0.1. Downgrading back to 13.0.0 and regenerating models resolves the issue, confirming it's a regression in the latest version.

Expected behavior

The export statement in src/models/index.js should use the same variable names that are defined within that file, so that no ReferenceError occurs and the application can build successfully.

For example, if the generator creates const RtcRecordType, it should also export RtcRecordType, not RTCRecordType.

Reproduction steps

  1. Use @aws-amplify/cli version 13.0.1.
  2. Define a GraphQL schema (schema.graphql) that contains an enum with an uppercase acronym, like RTC.
  3. Run the amplify codegen models command.
  4. Try to build the Vue application (e.g., using pnpm run dev with Vite).
  5. The build will fail with a ReferenceError originating from src/models/index.js.

Project Identifier

No response

Log output

# Put your logs below this line
Error:   Failed to scan for dependencies from entries:
C:/my-path/index.html

X [ERROR] "RTCRecordDetailType" is not declared in this file

src/models/index.js:221:2:
  221 │   RTCRecordDetailType,
      ╵   ~~~~~~~~~~~~~~~~~~~
X [ERROR] "RTCRecordDetailDataType" is not declared in this file

src/models/index.js:222:2:
  222 │   RTCRecordDetailDataType,
      ╵   ~~~~~~~~~~~~~~~~~~~~~~~
X [ERROR] "RTCRecordType" is not declared in this file

src/models/index.js:223:2:
  223 │   RTCRecordType,

Additional information

No response

Before submitting, please confirm:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-graphqlIssues related to GraphQL resources in the API categorybugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions