Fix "Copy entire row as JSON" button TypeError on non-string values (#2116)

## Summary

Fixes an operator-precedence bug in the "Copy entire row as JSON" button on the Search page. The `typeof value === 'string'` guard only applied to `value.startsWith('{')` but not `value.startsWith('[')`, so when a row contained a non-string value (number, boolean, etc.) the second `startsWith` call threw:

```
TypeError: s.startsWith is not a function
```

The fix moves the `typeof` check to guard both `startsWith` calls:

```diff
- (typeof value === 'string' && value.startsWith('{')) ||
- value.startsWith('[')
+ typeof value === 'string' &&
+ (value.startsWith('{') || value.startsWith('['))
```

### How to test locally or on Vercel

1. Open any Search page with results containing non-string column values (e.g. numeric or boolean fields).
2. Hover over a row and click the "Copy entire row as JSON" button (copy icon).
3. Verify the row is copied as valid JSON to the clipboard without a console error.

### References

- Related issue: HDX-4023


<div><a href="https://cursor.com/agents/bc-7aa1e5f4-ced5-4ee0-9585-4f473c5fca69"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/background-agent?bcId=bc-7aa1e5f4-ced5-4ee0-9585-4f473c5fca69"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div>



Co-authored-by: Cursor Agent <199161495+cursoragent@users.noreply.github.com>
This commit is contained in:
Warren Lee 2026-04-14 15:05:23 -07:00 committed by GitHub
parent cc714f909a
commit c4a1311e86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
"@hyperdx/app": patch
---
fix: Fix "Copy entire row as JSON" button crashing on rows with non-string values

View file

@ -35,8 +35,8 @@ const DBRowTableRowButtons: React.FC<DBRowTableRowButtonsProps> = ({
const parsedRow = Object.entries(cleanRow).reduce(
(acc, [key, value]) => {
if (
(typeof value === 'string' && value.startsWith('{')) ||
value.startsWith('[')
typeof value === 'string' &&
(value.startsWith('{') || value.startsWith('['))
) {
try {
acc[key] = JSON.parse(value);