Add async resolver for AWS config values - #751
Open
ubaskota wants to merge 4 commits into
Open
Conversation
# Conflicts: # packages/smithy-aws-core/src/smithy_aws_core/config/exceptions.py
jonathan343
requested changes
Jul 24, 2026
jonathan343
reviewed
Jul 27, 2026
|
|
||
| region: str | None = None | ||
| retry_mode: str | None = None | ||
| max_attempts: int | None = None |
Contributor
There was a problem hiding this comment.
We are promising to return int | None for max_attempts, however, this isn't true when a customer passes in a str. We cannot violate that contract.
>>> config = await AsyncAwsConfig.resolve(max_attempts="5")
>>> type(config.max_attempts)
<class 'str'>| async def resolve( | ||
| cls, | ||
| *, | ||
| profile: str | None = None, |
Contributor
There was a problem hiding this comment.
When a customer provides a profile value that doesn't actually exist, we throw a misleading error:
>>> c>>> config = await AsyncAwsConfig.resolve(profile="FOOBAR") from smithy_aws_core.config import AsyncAwsConfig
>>> config = await AsyncAwsConfig.resolve(profile="FOOBAR")
Traceback (most recent call last):
File "/Users/gytndd/.local/share/uv/python/cpython-3.12.13-macos-aarch64-none/lib/python3.12/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/Users/gytndd/.local/share/uv/python/cpython-3.12.13-macos-aarch64-none/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "<console>", line 1, in <module>
File "/Users/gytndd/dev/GitHub/temp6/smithy-python/packages/smithy-aws-core/src/smithy_aws_core/config/aws_config.py", line 105, in resolve
await instance._resolve_fields(overrides)
File "/Users/gytndd/dev/GitHub/temp6/smithy-python/packages/smithy-aws-core/src/smithy_aws_core/config/aws_config.py", line 165, in _resolve_fields
spec.validator(getattr(self, field_name))
File "/Users/gytndd/dev/GitHub/temp6/smithy-python/packages/smithy-aws-core/src/smithy_aws_core/config/validators.py", line 24, in validate_region
raise ConfigValidationError(
smithy_aws_core.config.exceptions.ConfigValidationError: Invalid value for 'region': None. Region is required and must be set.A common case will be when customers make a type in the profile name. We should provide a more accurate/helpful error.
| if result.value == "legacy": | ||
| warnings.warn( | ||
| "'legacy' retry mode is not supported, using 'standard' instead.", | ||
| DeprecationWarning, |
Contributor
There was a problem hiding this comment.
Usually DeprecationWarning means something works for this package today and won't in the future. We should use UserWarning instead since this is by design.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
Description of changes:
This change implements the async config resolution pipeline with
AsyncAwsConfigusing aresolve()classmethod as the only construction path. It addsSharedConfigContextfor holding memoized config file data,FieldSpecfor per-field resolution metadata, and provenance tracking viaConfigSource. Resolvers forregionandretry_strategy_optionsare included along with validators for both fields.Testing:
Note: This is a revision to the old PR (#738) that was automatically closed after the feature branch was merged.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.