-
Notifications
You must be signed in to change notification settings - Fork 30
fix: account ID based endpoints #1245
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
Conversation
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
| // TODO: Support maps as objects throughout the visitor | ||
| // This visitor assumes JMESPath 'objects' will be classes. DDB assumes JMESPath 'objects' will be maps |
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.
Should this be a FIXME instead of a TODO? Do we have a backlog item we can link here (SDK-KT-x)?
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.
Remove note about DDB
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.
Not sure if it should be a FIXME because the JMESPath visitor has been assuming classes > maps so far and we have had no apparent problems. Other services use JMESPath but this is the first instance I've seen of maps being used as objects. It might be a DDB only quirk or an indication that we took the wrong approach to objects
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.
Either way it sounds like we need a backlog item for this, to at least investigate the discrepancy
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.
Once that investigation is done we can go back and modify/create a comment here then?
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.
I think we should keep
// This visitor assumes JMESPath 'objects' will be classes. DDB assumes JMESPath 'objects' will be maps
But change it to mention the discrepancy between the smithy spec and the JMESPath spec for this function
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.
I just think every TODO should have an associated backlog task, otherwise it never gets done
| } | ||
| ] | ||
| }, | ||
| KeysFunctionPrimitivesIntegerEquals: { |
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.
Why was this integer primitives test removed?
| if (this.shape?.targetOrSelf(ctx.model)?.type == ShapeType.MAP) { | ||
| "${this.identifier}?.keys?.toList()" | ||
| } else { |
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.
What happens if the map has keys that aren't strings?
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.
Good catch, thanks
| // TODO: Support maps as objects throughout the visitor | ||
| // This visitor assumes JMESPath 'objects' will be classes. DDB assumes JMESPath 'objects' will be maps | ||
| private fun VisitedExpression.getKeys(): String = | ||
| if (this.shape?.targetOrSelf(ctx.model)?.type == ShapeType.MAP) { |
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.
style: unnecessary use of this
| @Test | ||
| fun testKeysFunctionPrimitivesIntegerEquals() = successTest( | ||
| fun testKeysFunctionMapStringEquals() = successTest( | ||
| GetFunctionKeysEqualsRequest { name = "test" }, | ||
| WaitersTestClient::waitUntilKeysFunctionPrimitivesIntegerEquals, | ||
| GetFunctionKeysEqualsResponse { primitives = EntityPrimitives { } }, | ||
| WaitersTestClient::waitUntilKeysFunctionMapStringEquals, | ||
| GetFunctionKeysEqualsResponse { maps = EntityMaps { strings = mapOf("key" to "value") } }, | ||
| ) |
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.
Question: Why did we modify this test case instead of creating a new one? Is the previous behavior no longer valid?
| // TODO: Support maps as objects throughout the visitor | ||
| // This visitor assumes JMESPath 'objects' will be classes. DDB assumes JMESPath 'objects' will be maps |
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.
Question: What does this comment mean? It seems like this visitor now assumes objects can be classes or maps.
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 keys function assumes objects can be classes or maps. The rest of the visitor does not. Hence the comment
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.
Our internal spec says:
Keys function - return a list of the keys in a map. This is the only supported function but is required for binding to key values.
Do we need to support classes?
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 JMESPath spec says
Returns an array containing the keys of the provided object
I guess we can get rid of support for classes if everyone else agrees
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.
No I believe we should support classes and it's an oversight that we didn't support it before. I was just wondering what else is required. Since nothing seems to be required for this getKeys function anymore I think we should move the TODO up to the class level or wherever's more appropriate for the scope.
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.
Updated the class with newer comments, let me know what you think
| // TODO: Support maps as objects throughout the visitor | ||
| // This visitor assumes JMESPath 'objects' will be classes. DDB assumes JMESPath 'objects' will be maps |
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.
Question: What's the remaining work to support maps as objects throughout the visitor?
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.
We would need to modify a decent chunk of the visitor. Anything that deals with objects
This comment has been minimized.
This comment has been minimized.
| Smithy spec: https://smithy.io/2.0/additional-specs/rules-engine/parameters.html#smithy-rules-operationcontextparams-trait | ||
| JMESPath spec: https://jmespath.org/specification.html#keys | ||
| TODO: Proactively support JMESPath objects as Kotlin maps throughout thr entire visitor if more instances of this behavior start popping up |
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.
"Proactively" and "if more instances of this behavior start popping up" are inconsistent. To be proactive we would need to identify any gaps and fix them now
Affected ArtifactsNo artifacts changed size |
Issue #
N/A
Description of changes
Adds support for Kotlin maps as JMESPath objects to the
keysfunctionBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.