Skip to content

Add config source interface and environment variable source for config resolution#640

Merged
ubaskota merged 4 commits intosmithy-lang:config_resolution_mainfrom
ubaskota:config_source
Feb 19, 2026
Merged

Add config source interface and environment variable source for config resolution#640
ubaskota merged 4 commits intosmithy-lang:config_resolution_mainfrom
ubaskota:config_source

Conversation

@ubaskota
Copy link

Issue #, if available:

Description of changes:
This change adds the ConfigSource protocol to smithy-core interfaces and implements EnvironmentSource in smithy-aws-core for resolving configuration values from environment variables. Includes unit tests covering protocol compliance, key-to-env-var mapping, edge cases, and no-caching behavior.

  • Tests *
    Added unit tests to validate the expected behavior. Verified that tests pass.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ubaskota ubaskota requested a review from a team as a code owner February 18, 2026 15:57
Comment on lines +32 to +35
config_value = os.environ.get(env_var)
if config_value is None:
return None
return config_value.strip()
Copy link
Contributor

Choose a reason for hiding this comment

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

Alternate option, commit this if you think it's more readable. Functionally, these are equivalent, just does the same thing in two fewer lines

Suggested change
config_value = os.environ.get(env_var)
if config_value is None:
return None
return config_value.strip()
if config_value := os.environ.get(env_var):
return config_value.strip()

Copy link
Contributor

@jonathan343 jonathan343 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 to me. There are one or two nits left you might want to consider

Comment on lines +28 to +29
:returns: The value from the environment variable (or empty string if set to empty),
or None if the variable is not set.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit - feels weird to call out empty string. The only special case we need to call out is if it's not set. Everything else we just return as is set in the environment

Suggested change
:returns: The value from the environment variable (or empty string if set to empty),
or None if the variable is not set.
:returns: The value from the environment variable (or None if the variable is not set).

Copy link
Author

Choose a reason for hiding this comment

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

I considered a phrasing similar to that, but wanted to explicitly clarify that setting an environment variable to an empty string returns "".

Copy link
Contributor

@arandito arandito left a comment

Choose a reason for hiding this comment

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

:shipit:

@ubaskota ubaskota merged commit 3ddcc64 into smithy-lang:config_resolution_main Feb 19, 2026
4 checks passed
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.

4 participants

Comments