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 to build for services with unsupported payloads #1187

Merged
merged 9 commits into from
Nov 15, 2019

Conversation

spfink
Copy link
Contributor

@spfink spfink commented Apr 3, 2019

With this change the code generator will no longer allow models to be build that have bodies for GET, DELETE or HEAD requests.

If a body is detected with one of these methods, the core will log a warning. I can switch this to also throwing an error but figured to throw a warning in case someone wanted to use our core and plugabble HTTP to support these.

Testing

Added test for code generation failure.

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 read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed
  • A short description of the change has been added to the CHANGELOG
  • 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

@spfink
Copy link
Contributor Author

spfink commented Apr 3, 2019

To note, this is what we could do post Pinpoint Email being updated to not use GET/DELETE with body. I guess I can make the code generator just log a warning until Pinpoint Email is changed.

*/
private void validateOperations(IntermediateModel model) {
List<String> methods = model.getOperations()
.entrySet()
Copy link
Contributor

Choose a reason for hiding this comment

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

values().stream()? You're not using the keys below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

},
"documentation":"<p>Used to associate a configuration set with a dedicated IP pool.</p>"
},
"Destination":{
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need all this, or can it be shortened?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shortened.

if (NO_BODY_METHODS.contains(request.method()) && request.contentStreamProvider().isPresent()) {
SdkStandardLogger.REQUEST_LOGGER.warn(() -> NO_BODY_METHODS +
" requests with bodies are not supported by the default SDK clients.");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this needed, if we have generator validation?

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 added this in case someone was using our core with their own plugged in client that supported GET requests with a body. Very unlikely to occur and won't occur for any AWS service. Can just throw or remove here if preferred though.

Copy link
Contributor

@millems millems Apr 8, 2019

Choose a reason for hiding this comment

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

I'd favor throwing or removing. Feels like complexity (and work the SDKs have to do with every method call) for not a lot of gain.

@spfink spfink force-pushed the finks/unsupported-payloads branch from 9ddf19c to f493979 Compare April 11, 2019 20:13
@codecov-io
Copy link

Codecov Report

Merging #1187 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1187      +/-   ##
============================================
+ Coverage     73.73%   73.76%   +0.03%     
  Complexity      660      660              
============================================
  Files           844      844              
  Lines         25936    25948      +12     
  Branches       1986     1988       +2     
============================================
+ Hits          19123    19140      +17     
+ Misses         5954     5949       -5     
  Partials        859      859
Flag Coverage Δ Complexity Δ
#unittests 73.76% <100%> (+0.03%) 660 <0> (ø) ⬇️
Impacted Files Coverage Δ Complexity Δ
.../awssdk/core/client/handler/BaseClientHandler.java 95.65% <ø> (ø) 0 <0> (ø) ⬇️
...awssdk/protocols/json/StructuredJsonGenerator.java 19.04% <100%> (-3.68%) 0 <0> (ø)
...mazon/awssdk/codegen/IntermediateModelBuilder.java 82.63% <100%> (+2.33%) 0 <0> (ø) ⬇️
...json/internal/marshall/JsonProtocolMarshaller.java 99.01% <100%> (ø) 0 <0> (ø) ⬇️
...o/netty/internal/http2/HttpOrHttp2ChannelPool.java 80.64% <0%> (-1.08%) 0% <0%> (ø)
...on/awssdk/services/kinesis/KinesisRetryPolicy.java 85.71% <0%> (ø) 0% <0%> (ø) ⬇️
...ssdk/core/internal/async/FileAsyncRequestBody.java 87.61% <0%> (+3.8%) 0% <0%> (ø) ⬇️
...ware/amazon/awssdk/codegen/AddExceptionShapes.java 91.66% <0%> (+4.16%) 0% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0e423db...f86b28b. Read the comment docs.

@stevenmhood
Copy link

stevenmhood commented Oct 28, 2019

Is there a way to know which APIs are impacted by this? I have a Lambda API call to GetLayerVersionByArn that's failing, and this seems possibly related. I think it's similar to 1078, but it's unclear.

I'll note that v1 of the SDK works without issue, and the same API call in Python has no problems.

@spfink spfink merged commit fd18eaf into master Nov 15, 2019
aws-sdk-java-automation pushed a commit that referenced this pull request Nov 15, 2019
aws-sdk-java-automation pushed a commit that referenced this pull request Nov 15, 2019
Revert "Merge pull request #1187 from aws/finks/unsupported-payloads"
@zoewangg zoewangg deleted the finks/unsupported-payloads branch August 19, 2020 22:46
aws-sdk-java-automation added a commit that referenced this pull request Feb 8, 2021
…e9d63e067

Pull request: release <- staging/63d2f8e1-88bd-4766-a368-60fe9d63e067
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.

4 participants