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

Defer projection failure until after plugins run #1416

Merged
merged 1 commit into from
Sep 28, 2022

Conversation

milesziemer
Copy link
Contributor

@milesziemer milesziemer commented Sep 20, 2022

Issue: #1277

This changes SmithyBuildImpl to continue applying plugins after one fails,
throwing the error (if present) after they have all completed. This is
useful for example when you want to see the serialized output of a model
you know is valid but a plugin is causing the whole build to fail. A new
test case was added to ensure that artifacts produced by valid plugins
are still created despite the build failing.

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

@milesziemer
Copy link
Contributor Author

milesziemer commented Sep 20, 2022

Opening this as a draft PR because it's pretty ugly, but not clear to me how to clean it up. Also, it just throws the first error from a plugin, but it might be useful to collect all plugin errors, and show the user which plugin caused which error. I didn't want to make any decisions though on what that would look like. Updated to log plugin errors.

This changes `SmithyBuildImpl` to continue applying plugins after one fails,
throwing the error (if present) after they have all completed. This is
useful for example when you want to see the serialized output of a model
you know is valid but a plugin is causing the whole build to fail. A new
test case was added to ensure that artifacts produced by valid plugins
are still created despite the build failing.
@milesziemer milesziemer changed the title Defer projection failure until after all plugins run Defer projection failure until after plugins run Sep 22, 2022
@milesziemer milesziemer marked this pull request as ready for review September 22, 2022 18:37
@milesziemer milesziemer requested a review from a team as a code owner September 22, 2022 18:37
@@ -283,13 +283,24 @@ private ProjectionResult applyProjection(
.model(projectedModel)
.events(modelResult.getValidationEvents());

// Keep track of the first error created by plugins to fail the build after all plugins have run
Throwable firstPluginError = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this only keep track of a single plugin error? This might be confusing if multiple plugins fail, but only the error for the first (or last?) ends up being thrown at the end.

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 only keeps track of the first plugin error. My initial thinking was to keep track of all plugin errors, but errors are handled per-projection (in SmithyBuild and BuildCommand). In order to not change these, we would need to aggregate all plugin errors into one error to throw as the projection error, but I wanted to defer making a decision on what exactly this would look like. Every plugin error is logged however, see here, but I think it would be nice to throw one big exception with all plugin errors

Copy link
Contributor

Choose a reason for hiding this comment

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

That sounds like a bigger change that could be done later, but this still seems like a good improvement for now.

@milesziemer milesziemer merged commit 5281e72 into smithy-lang:main Sep 28, 2022
@milesziemer milesziemer deleted the defer-plugin-failure branch September 28, 2022 13:53
kstich added a commit to kstich/smithy that referenced this pull request Sep 28, 2022
milesziemer pushed a commit that referenced this pull request Sep 28, 2022
milesziemer added a commit to milesziemer/smithy that referenced this pull request Sep 29, 2022
milesziemer added a commit to milesziemer/smithy that referenced this pull request May 4, 2023
This changes `SmithyBuildImpl` to continue applying plugins after one fails,
throwing the error (if present) after they have all completed. This is
useful for example when you want to see the serialized output of a model
you know is valid but a plugin is causing the whole build to fail. A new
test case was added to ensure that artifacts produced by valid plugins
are still created despite the build failing.

This was originally implemented in smithy-lang#1416, but was rolled back in smithy-lang#1429
as a precaution since we had an unrelated issue ocurring at the time.
milesziemer added a commit that referenced this pull request May 4, 2023
This changes `SmithyBuildImpl` to continue applying plugins after one fails,
throwing the error (if present) after they have all completed. This is
useful for example when you want to see the serialized output of a model
you know is valid but a plugin is causing the whole build to fail. A new
test case was added to ensure that artifacts produced by valid plugins
are still created despite the build failing.

This was originally implemented in #1416, but was rolled back in #1429
as a precaution since we had an unrelated issue ocurring at the time.
syall pushed a commit to Xtansia/smithy that referenced this pull request Aug 11, 2023
This changes `SmithyBuildImpl` to continue applying plugins after one fails,
throwing the error (if present) after they have all completed. This is
useful for example when you want to see the serialized output of a model
you know is valid but a plugin is causing the whole build to fail. A new
test case was added to ensure that artifacts produced by valid plugins
are still created despite the build failing.

This was originally implemented in smithy-lang#1416, but was rolled back in smithy-lang#1429
as a precaution since we had an unrelated issue ocurring at the time.
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