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
fix(graphql-key-transformer): prevent non-scalar key fields #5319
fix(graphql-key-transformer): prevent non-scalar key fields #5319
Conversation
resolves aws-amplify#5300 Logic for 'isScalar' treated lists as scalar types. This allowed indexes to be created with invalid key types. This modifies the isScalar function to return false for list types, and updates other areas as needed with a new 'isScalarOrScalarList' function Includes new test which fails without this fix. Fixes adjacent tests failing because of missing model transforms, and not for the stated reason.
dcd68ef
to
71f6cfd
Compare
71f6cfd
to
45e68ed
Compare
Codecov Report
@@ Coverage Diff @@
## master #5319 +/- ##
==========================================
+ Coverage 57.76% 57.77% +0.01%
==========================================
Files 406 406
Lines 18630 18640 +10
Branches 3721 3725 +4
==========================================
+ Hits 10761 10769 +8
- Misses 7187 7189 +2
Partials 682 682
Continue to review full report at Codecov.
|
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.
LGTM - Thanks for your contribution!
This pull request has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Issue #, if available:
#5300
Description of changes:
Logic for 'isScalar' function treated lists as scalar types. Lists are not scalar, and are not valid primary key types. This allowed indexes to be created with invalid key types, resulting in runtime errors.
This modifies the isScalar function to return false for list types, and updates other areas as needed with a new 'isScalarOrScalarList' function. Added explicit list checks where needed, type narrowing, and changes to satisfy compiler.
Includes new test which fails without this fix.
Fixes adjacent tests failing because of missing model transforms, and not for the stated reason.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.