-
Notifications
You must be signed in to change notification settings - Fork 232
Open
Labels
S-triageStatus: This issue is waiting on initial triage. More Info: https://tinyurl.com/25uty9w5Status: This issue is waiting on initial triage. More Info: https://tinyurl.com/25uty9w5
Description
The toBool helper function can lead to unexpected behavior. Any string value for an environment variable that is not '1', 'true', or 'yes' (case-insensitive) will be evaluated as false by the current implementation. For example, if a user makes a typo like PREFUND_ENABLED=ture, it will be interpreted as false without any warning, which could be surprising. A more robust implementation would explicitly handle both truthy and falsy values, and treat any other unrecognized string as an invalid input (by returning undefined), letting zod handle defaults or throw an error.
const toBool = (value?: string) => value !== undefined ? ([_x22_1_x22_, _x22_true_x22_, _x22_yes_x22_].includes(value.toLowerCase()) ? true : [_x22_0_x22_, _x22_false_x22_, _x22_no_x22_].includes(value.toLowerCase()) ? false : undefined) : undefined
Originally posted by @gemini-code-assist[bot] in #2493 (comment)
Metadata
Metadata
Assignees
Labels
S-triageStatus: This issue is waiting on initial triage. More Info: https://tinyurl.com/25uty9w5Status: This issue is waiting on initial triage. More Info: https://tinyurl.com/25uty9w5
Type
Projects
Status
⚡ Building 🧱