Skip to content

chore(enum-updater): support adding manual static enum mappings #34441

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

Merged
merged 6 commits into from
May 15, 2025

Conversation

paulhcsun
Copy link
Contributor

Issue # (if applicable)

Closes #.

Reason for this change

Manual changes to the static-enum-mapping.json would be overwritten the next time the workflow was run.

Description of changes

Add a new file manual-enum-mapping.json that allows maintainers to add manual mappings that will be used over any matching mapping that the script calculates.

Manual mappings should be added in the form:

{
    "serviceName": {
      "CdkEnumName": {
        "cdk_path": "path/to/cdkEnum",
        "sdk_service": "serviceName",
        "sdk_enum_name": "AwsEnumThatWeWantThisToMapTo",
        "match_percentage": 1.0,
        "manual": true
      }
    }
}

For example:

{
    "ec2": {
      "VpcEndpointIpAddressType": {
        "cdk_path": "aws-cdk/packages/aws-cdk-lib/aws-ec2/lib/vpc-endpoint.ts",
        "sdk_service": "ec2",
        "sdk_enum_name": "IpAddressType",
        "match_percentage": 1.0,
        "manual": true
      }
    }
}

Description of how you validated changes

Manual + unit testing

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation aws-cdk-automation requested a review from a team May 13, 2025 01:06
@github-actions github-actions bot added the p2 label May 13, 2025
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label May 13, 2025
@paulhcsun paulhcsun marked this pull request as ready for review May 13, 2025 01:09
@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label May 13, 2025
@@ -103,6 +104,16 @@ interface UnmatchedEnums {
};
}

export interface ManualMappingEntry extends StaticMappingEntry {
manual: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would this always be true? what if user accidentally add a entry to the manual-enum-mapping.json but add it as false?
how does manual get used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should always be true but the value doesnt actually matter. When creating the static mapping, we only check if an entry for the specific enum exists by the enum name, if so, we just use the entry in the manual mapping instead which would include this manual field.

Basically the manual field just exists so that we know a static mapping was manually updated when we look at the entry in static-enum-mapping.json.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this field from the manual mapping file and let the code logic add it.

sdk_service: "amplify",
sdk_enum_name: "OverrideManualEnum",
match_percentage: 1.0,
manual: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happen if you add it as false? would it still override?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we check for the enum by its name, not by whether or not manual == true.

if (!staticMapping[module]) {
staticMapping[module] = {};
}
staticMapping[module][enumName] = manualEnumMappings[module][enumName];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the manual: true could be added here if it was not in the manual mapping file, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated it to add the manual: true here instead of having it specified in the manual overrides json file.

@@ -103,6 +104,16 @@ interface UnmatchedEnums {
};
}

export interface ManualMappingEntry extends StaticMappingEntry {
manual: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this field from the manual mapping file and let the code logic add it.

Copy link
Contributor

mergify bot commented May 14, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label May 14, 2025
Copy link
Contributor

mergify bot commented May 14, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

Copy link
Contributor

mergify bot commented May 14, 2025

This pull request has been removed from the queue for the following reason: pull request branch update failed.

The pull request can't be updated.

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio requeue comment.

@samson-keung
Copy link
Contributor

Manually updated PR with main as main has new commits that changed workflow files.

Copy link
Contributor

mergify bot commented May 15, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 0786e05
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

mergify bot commented May 15, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 967ee9d into aws:main May 15, 2025
16 checks passed
Copy link
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
contribution/core This is a PR that came from AWS. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants