Add support for sdk_ua_app_id.#653
Add support for sdk_ua_app_id.#653ubaskota merged 4 commits intosmithy-lang:config_resolution_mainfrom
Conversation
jonathan343
left a comment
There was a problem hiding this comment.
Had a few comments. I also noticed there are no validators for any of these options. I know at least the user agent app ID will need it:
Valid values: String with maximum length of 50. Letters, numbers and the following special characters are allowed: !,#,$,%,&,',*,+,-,.,^,_,`,|,~.
| .build(); | ||
|
|
||
| public static final ConfigProperty USER_AGENT_EXTRA = ConfigProperty.builder() | ||
| .name("user_agent_extra") |
There was a problem hiding this comment.
Why was this config option added? This config option isn't standardized across all SDKs (source). By adding it here we're now reading AWS_USER_AGENT_EXTRA from the environment which we shouldn't be doing.
| .documentation("A unique and opaque application ID that is appended to the User-Agent header.") | ||
| .nullable(false) | ||
| .useDescriptor(true) | ||
| .defaultValue("''") |
There was a problem hiding this comment.
Is there any limitation with keeping the default to None? This feels weird to me.
There was a problem hiding this comment.
I thought users would be able to add it without first checking if the value is None if the default is an empty string. But I see why returning None would be a better choice. I will update it.
| .defaultValue("''") | ||
| .build(); | ||
|
|
||
| public static final ConfigProperty ENDPOINT_URL = ConfigProperty.builder() |
There was a problem hiding this comment.
I haven't tested but it looks like we now have endpoint_uri and endpoint_url. Since there are not other changes, if someone sets export AWS_ENDPOINT_URL="...", then config.endpoint_url will resolve correctly, but it won't actually be used by the SDK since we're using endpoint_uri still.
This one is a bit more complicated since smithy python stuff uses endpoint_uri. Can we leave the existing endpoint_uri but map to endpoint_url config options?
| .build()) | ||
| .documentation("The retry strategy or options for configuring retry behavior. Can be either a configured RetryStrategy or RetryStrategyOptions to create one.") | ||
| .build(), | ||
| ConfigProperty.builder() |
There was a problem hiding this comment.
This will add all of these to generic clients; can we keep them as AWS specific for now?
| .type(Symbol.builder().name("str").build()) | ||
| .documentation("A unique and opaque application ID that is appended to the User-Agent header.") | ||
| .build(), | ||
| ConfigProperty.builder() |
There was a problem hiding this comment.
endpoint_url and endpoint_uri are effectively the same. We should address this in the long run since the SDKs have standardized on endpoint_url, but we currently only accept endpoint_uri.
For now, let's just remove the duplicate endpoint_url.
36f41f8 to
7146d45
Compare
| default_value=RetryStrategyOptions( | ||
| retry_mode="standard", max_attempts=3 | ||
| ), | ||
| default_value=RetryStrategyOptions(retry_mode="standard"), |
There was a problem hiding this comment.
Can you help me understand why we are making these changes?
There was a problem hiding this comment.
The default value for retry_strategy should only specify retry_mode, since max_attempts will be determined later based on the selected retry mode. It would have worked either way though.
| ) | ||
|
|
||
|
|
||
| def validate_and_sanitize_ua_string( |
There was a problem hiding this comment.
So just to record this here for posterity - we did specifically ask for this to be added; at the time, we weren't aware that it would be duplicate logic.
This kind of points to a minor issue with smithy-python that I started a discussion on, but we won't be acting on it for now. We are putting an HTTP-specific concept (user-agent) in a non-HTTP-specific place (client config). While we could theoretically reuse the user agent string for another protocol, the same concepts may or may not apply.
As of today, it happens as a plugin during the modify-before-signing event. While a user shouldn't be able to set an invalid user agent that we know will fail on the config, we could theoretically pass user agent components to the user agent part of the HTTP code from somewhere other than the config in the future. On the other hand, we could wind up using another plugin in the future that loses this behavior and miss it that way; neither is a perfect place for this logic to be.
Right now I'd lean towards removing validations beyond typing for this input. If these requirements somehow change in the future based on who is consuming the user agent, it's better to keep these downstream where the header actually gets set.
|
|
||
|
|
||
| class TestValidateUaString: | ||
| def test_allows_string(self) -> None: |
There was a problem hiding this comment.
Nit: all of these tests except the error test could easily be one test with pytest.mark.parametrize; everything is only validating that it's passed through, so the test body could just be
assert validate_ua_string(value) == value
| assert region == "us-west-2" | ||
| assert retry_mode == "adaptive" | ||
|
|
||
| def test_unresolved_ua_app_id_defaults_to_none(self) -> None: |
There was a problem hiding this comment.
Can you help me understand what value this test provides? Are we just testing that the default works?
I don't think this test has anything to do with the other code changes- again, unless you changed ConfigProperty and broke it, this test wouldn't fail? There's nothing about this PR that is being tested here, so I'd hope we already had proper tests on TestConfigProperty
Issue #, if available:
Description of changes:
Add codegen support for a new config property:
sdk_ua_app_id, along with a validator. For AWS SDKs, these are generated as descriptor-based properties with config resolver and default values.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.