Commit d1002d1
committed
fix: ensure phrase is a string (COR-10013) (#593)
### TL;DR
Fix variable replacement to handle non-string inputs by converting them to strings.
### What changed?
Modified the `replaceVariables` function to explicitly convert non-string inputs to strings before processing. Previously, the function would attempt to trim potentially non-string values, which was rarely but occasionally resulting in a `phrase?.trim is not a function` error. Now, the function safely converts the input to a string first, handling all type issues.
### How to test?
1. Call `replaceVariables` with different types of inputs:
- String values
- Numbers
- Undefined values
- Null values
- Objects
2. Verify that the function correctly converts all inputs to strings without errors
3. Ensure that variable replacement still works as expected with the converted strings
### Why make this change?
This change improves the robustness of the `replaceVariables` function by ensuring it can safely handle any type of input. Previously, calling methods like `trim()` on non-string values could cause runtime errors. This fix ensures consistent behavior regardless of input type, preventing potential crashes when the function receives unexpected data types.
Co-authored-by: Amanda <amanda.steinhauer@voiceflow.com>1 parent f36349e commit d1002d1
1 file changed
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
| 88 | + | |
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
| |||
0 commit comments