aws / aws-pdk

The AWS PDK provides building blocks for common patterns together with development tools to manage and build your projects.
https://aws.github.io/aws-pdk/
Apache License 2.0
372 stars 74 forks source link

[BUG] (short issue description)Codegen for mocks fails on filename case mismatch. #794

Open vaneek opened 4 months ago

vaneek commented 4 months ago

Describe the bug

Using the PDK shopping list demo , the generated code breaks during the build process with the following error;

File "/home/ec2-user/environment/tpdk/packages/api/generated/infrastructure/python/orgapi_python_infra/mock_integrations.py", line 23, in delete_shopping_list_200 infra: with open(path.join(MOCK_DATA_PATH, "DELETE{}-200.json".format("/shopping-list/{shoppingListId}".replace("/", "-")).lower()), "r") as f: infra: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ infra: FileNotFoundError: [Errno 2] No such file or directory: '/home/ec2-user/environment/tpdk/packages/api/generated/infrastructure/python/orgapi_python_infra/../mocks/delete-shopping-list-{shoppinglistid}-200.json' The code performs a .lower() on the whole path rather than just the verb. The name of the generated json file is delete-shopping-list-{shoppingListId}-200.json. This may also catch upstream directories with caps in their name.

The smithy definition is;

@http(method: "DELETE", uri: "/shopping-list/{shoppingListId}") @handler(language: "python") operation DeleteShoppingList { input := { @required @httpLabel shoppingListId: ShoppingListId } output := with [ShoppingListIdMixin] {} errors: [NotFoundError] }

Expected Behavior

Respect actual path/filenames.

Current Behavior

performs a .lower() on path and filename.

Reproduction Steps

Using the PDK shopping list demo

The smithy definition is;

@http(method: "DELETE", uri: "/shopping-list/{shoppingListId}") @handler(language: "python") operation DeleteShoppingList { input := { @required @httpLabel shoppingListId: ShoppingListId } output := with [ShoppingListIdMixin] {} errors: [NotFoundError] }

Possible Solution

No response

Additional Information/Context

No response

PDK version used

current

What languages are you seeing this issue on?

Python

Environment details (OS name and version, etc.)

AL2023

github-actions[bot] commented 2 months ago

This issue is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon. If you wish to exclude this issue from being marked as stale, add the "backlog" label.

github-actions[bot] commented 1 month ago

Closing this issue as it hasn't seen activity for a while. Please add a comment @mentioning a maintainer to reopen. If you wish to exclude this issue from being marked as stale, add the "backlog" label.

vaneek commented 1 month ago

So ignore it and it will go away?

cogwirrel commented 2 weeks ago

Hi @vaneek,

Sorry this was auto-closed - I'm just back from leave!

Reopening this as it's definitely an issue! This could also possibly be related to #793

Cheers, Jack