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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

belkhadir
Copy link

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
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.

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