-
Notifications
You must be signed in to change notification settings - Fork 226
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
Add service id to the error message to aid debugging #2483
Add service id to the error message to aid debugging #2483
Conversation
TopDownIndex topDownIndex = TopDownIndex.of(model); | ||
AwsTagIndex tagIndex = AwsTagIndex.of(model); | ||
for (ServiceShape service : model.getServiceShapes()) { | ||
for (ResourceShape resource : topDownIndex.getContainedResources(service)) { | ||
boolean resourceLikelyTaggable = false; | ||
if (resource.hasTrait(TaggableTrait.class)) { | ||
if (resource.hasTrait(TaggableTrait.class) && service.getResources().contains(resource.getId())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't right. It's only checking resource
shapes bound directly to the service, meaning this won't run on nested resources (service -> parent -> child - child won't be checked.)
TopDownIndex topDownIndex = TopDownIndex.of(model); | ||
AwsTagIndex tagIndex = AwsTagIndex.of(model); | ||
for (ServiceShape service : model.getServiceShapes()) { | ||
for (ResourceShape resource : topDownIndex.getContainedResources(service)) { | ||
boolean resourceLikelyTaggable = false; | ||
if (resource.hasTrait(TaggableTrait.class)) { | ||
if (resource.hasTrait(TaggableTrait.class) && service.getResources().contains(resource.getId())) { | ||
events.addAll(validateResource(model, resource, service, tagIndex)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error messages in validateResource
that are related to the service's tagging operations should include the ID of the service shape to aid in debugging.
0bf70f9
to
483d36b
Compare
483d36b
to
a496f79
Compare
@@ -87,7 +87,6 @@ private List<ValidationEvent> validateResource( | |||
// list or tag keys input or output member | |||
// 2. Tagging via APIs specified in the @taggable trait which are validated | |||
// through the tag property, and must be resource instance operations | |||
//Caution: avoid short circuiting behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is misleading, you only want to avoid short circuiting if you are expecting a side effect, that's not the case here.
if (!(isServiceWideTaggable || isInstanceOpTaggable)) { | ||
events.add(error(resource, "Resource does not have tagging CRUD operations and is not compatible" | ||
+ " with service-wide tagging operations.")); | ||
if (!isServiceWideTaggable && !isInstanceOpTaggable) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition written this way expresses more clearly what we want.
Optional<String> property = resource.expectTrait(TaggableTrait.class).getProperty(); | ||
if (property.isPresent()) { | ||
if (operationId.isPresent()) { | ||
if (operationId.isPresent()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only way for this code to branch to true
is for when the optional operationId
is present. I moved it up to avoid unneeded work when that's not true.
Background
When a resource is in the closure of more than one service the
TaggableResource
error won't say for which one it failed, e.g.,This change add the service to better understand where the issue is.
While there I also made minor changes to improve the code around.
Testing
Links
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.