Skip to content

Replace raw source strings with typed SourceInfo dataclasses#652

Merged
ubaskota merged 5 commits intosmithy-lang:config_resolution_mainfrom
ubaskota:update_config_source
Mar 13, 2026
Merged

Replace raw source strings with typed SourceInfo dataclasses#652
ubaskota merged 5 commits intosmithy-lang:config_resolution_mainfrom
ubaskota:update_config_source

Conversation

@ubaskota
Copy link

Issue #, if available:

Description of changes:
Replace raw source strings with typed SourceInfo dataclasses (SimpleSource and ComplexSource) for config source tracking. This provides structured source information and type safety across resolvers, validators, and properties.

Previously, sources were tracked as plain strings (e.g., "retry_mode=environment, max_attempts=config_file"). Now, simple sources use SimpleSource("environment") and complex sources use ComplexSource({"retry_mode": "environment", "max_attempts": "config_file"}).

Tests
The existing tests are updated to match the changed behavior and verified that all of them 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 March 10, 2026 04:06
Examples: region from environment, max_attempts from config file.
"""

name: str
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we introduced the SourceName enum for type safety, this should now be str: SimpleSource.

Copy link
Author

Choose a reason for hiding this comment

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

Its not possible to do this now due to the nature of our tests, so added a TODO.

Copy link
Contributor

Choose a reason for hiding this comment

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

The point of this PR is to make sure that the source's name is one of a small number of acceptable values. If we aren't checking that those values are valid when we create the source via strict typing, the point of this PR is moot.

If we can't properly test code, sometimes that may mean that it's poorly written code. Often, it means we are either testing things that aren't valuable or we haven't thought of the right way to test them.

The tests are here to make sure that the code works, not the other way around.

could be from different sources: {"retry_mode": "environment", "max_attempts": "config_file"}
"""

components: dict[str, str]
Copy link
Contributor

Choose a reason for hiding this comment

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

This should also use the new enum: dict[str, SimpleSource].

@ubaskota ubaskota merged commit 6c4b348 into smithy-lang:config_resolution_main Mar 13, 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.

3 participants