Skip to content

[Merged by Bors] - fix: ensure phrase is a string (COR-10013)#593

Closed
amandasteinhauer wants to merge 2 commits intomasterfrom
amanda/defensive-phrase-typing/COR-10013
Closed

[Merged by Bors] - fix: ensure phrase is a string (COR-10013)#593
amandasteinhauer wants to merge 2 commits intomasterfrom
amanda/defensive-phrase-typing/COR-10013

Conversation

@amandasteinhauer
Copy link
Contributor

@amandasteinhauer amandasteinhauer commented Feb 13, 2026

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.

@linear
Copy link

linear bot commented Feb 13, 2026

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@amandasteinhauer amandasteinhauer marked this pull request as ready for review February 13, 2026 20:52
Apply suggested changes
@sonarqubecloud
Copy link

Copy link
Contributor Author

bors r+

bors-vf bot pushed a commit that referenced this pull request Feb 13, 2026
### 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>
@bors-vf
Copy link

bors-vf bot commented Feb 13, 2026

Pull request successfully merged into master.

Build succeeded:

@bors-vf bors-vf bot changed the title fix: ensure phrase is a string (COR-10013) [Merged by Bors] - fix: ensure phrase is a string (COR-10013) Feb 13, 2026
@bors-vf bors-vf bot closed this Feb 13, 2026
@bors-vf bors-vf bot deleted the amanda/defensive-phrase-typing/COR-10013 branch February 13, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants