Skip to content

Replace hardcoded config fallback version with dynamic constant #381

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

Merged

Conversation

belkhadir
Copy link
Contributor

Previously, when loading the config file, the fallback version "0.3.0" was hardcoded to handle unversioned configs from earlier releases.

This MR replaces the hardcoded value with the centralized SwiftlyCore.version constant, ensuring consistency across the codebase and reducing the risk of version mismatches in the future.

Previously, when loading the config file, the fallback version `”0.3.0"` was hardcoded
to handle unversioned configs from earlier releases.

This commit replaces the hardcoded value with the centralized `version` constant,
ensuring consistency across the codebase and reducing the risk of version mismatches
in the future.
@cmcgee1024
Copy link
Member

Thank you for this contribution.

The code is working as designed at the time, which is that the version would have to be "0.3.0" (or earlier) if there's no version field in the config.json. This sets the version so that it can be compared further down the line for any migrations of the swiftly installation.

Since swiftly does not support upgrading from "0.3.0" and earlier the change here might be to make the version field mandatory, and remove this set if it's not set code.

This commit aligns with the decision to drop support for configurations without a version field (pre-0.3.0). The `version` property in `Config` is now non-optional and must be explicitly set at creation.

- Removed the fallback assignment to "0.3.0"
- Updated all code to require and use non-optional `version`
- Adjusted the config initializer to take `version` as a parameter
- Simplified conditional checks and eliminated `.version?`

This ensures that swiftly no longer silently accepts or upgrades legacy configurations without an explicit version.
@belkhadir
Copy link
Contributor Author

Thanks for the clarification; that makes perfect sense.

I've updated the code to make the version field in the config mandatory and removed the fallback to "0.3.0". The initializer now requires a version, and all optional checks have been cleaned up.

@cmcgee1024
Copy link
Member

@belkhadir there's a few compile errors in the tests, and some code reformatting needed for this. To reformat the code you can use swift run swiftformat Sources Tests

@belkhadir
Copy link
Contributor Author

@cmcgee1024 Thanks for the feedback! I've fixed the test compilation errors and applied formatting.

I also noticed a two warning (No 'async' operations occur within 'await' expression) that could be cleaned up. Would you prefer I include that change in this PR or open a separate one to keep things focused?

@cmcgee1024
Copy link
Member

I also noticed a two warning (No 'async' operations occur within 'await' expression) that could be cleaned up. Would you prefer I include that change in this PR or open a separate one to keep things focused?

@belkhadir let's keep this PR focused on this one area. Additional PR's are welcome. Thanks.

@cmcgee1024 cmcgee1024 merged commit e6a78f5 into swiftlang:main Jul 9, 2025
24 checks passed
@belkhadir belkhadir deleted the refactor/config-fallback-version branch July 19, 2025 12:56
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.

2 participants