feat(kernel): ✨ Improve environment schema validation - #17
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a740a0c43a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| TChoices extends readonly KernelEnvironmentValue[] | undefined = | ||
| | readonly KernelEnvironmentVariablePrimitive<TType>[] | ||
| | undefined, | ||
| > { | ||
| readonly choices?: TChoices; |
There was a problem hiding this comment.
Bind choices to the declared variable type
When a schema is passed through KernelEnvironmentSchema/new Kernel, TType defaults to the full union, so choices?: TChoices accepts any KernelEnvironmentValue[] rather than choices that match the entry's type. For example, { HTTP_PORT: { type: 'number', choices: ['3000'] } } type-checks, but the runtime parses HTTP_PORT=3000 to the number 3000 and then includes compares it with the string choice, so validation always throws for that config. Please correlate choices with KernelEnvironmentVariablePrimitive<TType> so invalid schemas are rejected at compile time.
Useful? React with 👍 / 👎.
|
Replaced by the breaking-change branch and PR because the kernel registration contract changes are intentionally breaking. |
Summary
Validation