Skip to content
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

Change guessType to retain value types if they are known #22349

Merged
merged 7 commits into from May 2, 2024

Conversation

hanneskuettner
Copy link
Contributor

Scope

If configuration parameters are read from any location, where they already have a correct type, e.g. from a .js or .yaml file this information is lost, and can actually lead to guessType guessing the wrong type, e.g. 'number' for a boolean value.

What's changed:

  • Change guessType to retain the type of unknown value, if they are boolean, number or array.

Potential Risks / Drawbacks

  • I don't think we explicitly allowed, e.g. DB_EXCLUDE_TABLES: ['foo', 'bar'] before, but would allow it now
  • Anyone who has been abusing ANY_CONFIG_VALUE: true to equal 1 will have a problem now (let's not hope so)

Review Notes / Questions

  • Does this warrant a notice in the changeset?
  • Should we add test cases to cast.test.ts that cover all combinations of cast flags and values and test it without mocking all the functions in between? Right now everything is mocked out.

Fixes #21744

Copy link

changeset-bot bot commented Apr 30, 2024

🦋 Changeset detected

Latest commit: 0625e49

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@directus/env Patch
@directus/api Patch
directus Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@licitdev licitdev left a comment

Choose a reason for hiding this comment

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

Guessing accuracy increased! 🚀

@licitdev licitdev merged commit 97bf47e into main May 2, 2024
4 checks passed
@licitdev licitdev deleted the fix-21744-env-variable-casting branch May 2, 2024 09:42
@github-actions github-actions bot added this to the Next Release milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Boolean environment variables are cast to numbers
2 participants