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

chore: remove all asserts in source code, replace with error for internal exceptions, and InvalidDirectiveExceptions for input errors #765

Merged
merged 1 commit into from
Aug 25, 2022

Conversation

alharris-at
Copy link
Contributor

@alharris-at alharris-at commented Aug 24, 2022

Description of changes

Today, we have a number of assert statements in source which we shouldn't do. This PR replaces those with either Errors for faults, or InvalidDirectiveExceptions where invalid input is caught, to provide better visibility into operator error vs bugs.

Issue #, if available

N/A

Description of how you validated changes

I would have like to add more unit tests, but given the surface area of the change that was slowing me down, so I'm relying on e2e tests to verify all use-cases here.

Checklist

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

@alharris-at alharris-at requested a review from a team as a code owner August 24, 2022 23:28
Copy link
Contributor

@sundersc sundersc left a comment

Choose a reason for hiding this comment

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

LGTM. Left few comments.

…rnal exceptions, and InvalidDirectiveExceptions for input errors
Copy link
Contributor

@sundersc sundersc left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov-commenter
Copy link

Codecov Report

Merging #765 (9a4f620) into main (6a7b9f3) will increase coverage by 0.24%.
The diff coverage is 85.46%.

@@            Coverage Diff             @@
##             main     #765      +/-   ##
==========================================
+ Coverage   63.14%   63.39%   +0.24%     
==========================================
  Files         278      278              
  Lines       18125    18220      +95     
  Branches     4375     4431      +56     
==========================================
+ Hits        11445    11550     +105     
+ Misses       6093     6074      -19     
- Partials      587      596       +9     
Impacted Files Coverage Δ
...plify-graphql-auth-transformer/src/utils/schema.ts 94.69% <ø> (ø)
...searchable-transformer/src/cdk/create-cfnOutput.ts 100.00% <ø> (ø)
...transformer-core/src/transformer-context/output.ts 2.43% <0.00%> (-0.35%) ⬇️
...graphql-transformer-core/src/utils/schema-utils.ts 18.18% <0.00%> (-4.55%) ⬇️
...graphql-elasticsearch-transformer/src/resources.ts 100.00% <ø> (ø)
...ansformer-core/src/transformer-context/resolver.ts 5.69% <9.09%> (-0.16%) ⬇️
...fy-graphql-auth-transformer/src/resolvers/field.ts 71.42% <33.33%> (+2.04%) ⬆️
...-graphql-auth-transformer/src/accesscontrol/acm.ts 94.00% <50.00%> (+9.00%) ⬆️
...mplify-graphql-relational-transformer/src/utils.ts 79.24% <50.00%> (-2.17%) ⬇️
...l-transformer-core/src/transformation/transform.ts 16.00% <50.00%> (-0.32%) ⬇️
... and 44 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@phani-srikar phani-srikar left a comment

Choose a reason for hiding this comment

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

Looks Good. Nice to have these changes put in!

* @param ctx the cli invocation context
* @returns the constructed sort field, or null if no sort field can be created
*/
export const tryAndCreateSortField = (
Copy link
Contributor

Choose a reason for hiding this comment

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

appreciate this refactor!

@alharris-at alharris-at merged commit d7bf74d into main Aug 25, 2022
@alharris-at alharris-at deleted the replace-asserts branch August 25, 2022 01:23
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.

None yet

4 participants