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

Fail codegen for Query protocol operations with explicit String payload #4553

Merged
merged 3 commits into from
Oct 6, 2023

Conversation

davidh44
Copy link
Contributor

@davidh44 davidh44 commented Oct 5, 2023

Motivation and Context

Explicit String payloads are not supported for Query protocols

Modifications

Update codegen to fail if there is Query protocol operation with explicit String payload

Update Json codegen test classes which were missed in previous PR - string can be lowercase when calling shape.getType()

Testing

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

@davidh44 davidh44 requested a review from a team as a code owner October 5, 2023 23:01
@@ -73,7 +74,7 @@ private static boolean isBlobShape(Shape shape) {
* @return True if shape is a String type. False otherwise
*/
private static boolean isStringShape(Shape shape) {
return shape != null && "String".equals(shape.getType());
return shape != null && shape.getType().equalsIgnoreCase("String");
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's keep the original ordering and compare to the constant: "String".equalsIgnoreCase(shape.getType())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1

@@ -179,6 +180,12 @@ public Map<String, OperationModel> constructOperations() {
if (input != null) {
String originalShapeName = input.getShape();
String inputShape = namingStrategy.getRequestClassName(operationName);

if (isQueryProtocolWithExplicitStringPayload(c2jShapes, c2jShapes.get(inputShape))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like the idea of doing validation in here since we're not doing it for anything else. Can we do this validation as a preprocessor instead?

similar to
public final class NewAndLegacyEventStreamProcessor implements CodegenCustomizationProcessor {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense, moving to preproccesor

@sonarcloud
Copy link

sonarcloud bot commented Oct 6, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

83.7% 83.7% Coverage
0.0% 0.0% Duplication

@davidh44 davidh44 merged commit 13985e0 into master Oct 6, 2023
14 of 15 checks passed
@davidh44 davidh44 deleted the hdavidh/fail-codegen-string-payload-query-protocol branch October 6, 2023 22:38
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

Successfully merging this pull request may close these issues.

2 participants