Skip to content

Commit b21ddcd

Browse files
CopilotneSpecc
andcommitted
Fix empty array handling to be consistent with empty objects
Co-authored-by: neSpecc <3684889+neSpecc@users.noreply.github.com>
1 parent f3d08d0 commit b21ddcd

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

workers/sentry/src/utils/converter.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ function flattenObject(obj: unknown, prefix = ''): string[] {
2020
}
2121

2222
if (Array.isArray(obj)) {
23+
if (obj.length === 0) {
24+
return [ prefix ? `${prefix}=[]` : '[]' ];
25+
}
26+
2327
obj.forEach((value, index) => {
2428
const key = prefix ? `${prefix}.${index}` : String(index);
2529

workers/sentry/tests/converter.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ describe('converter utils', () => {
244244

245245
expect(backtrace?.[0].arguments).toEqual([
246246
'emptyObject={}',
247+
'emptyArray=[]',
247248
'normalValue=test',
248249
]);
249250
});

0 commit comments

Comments
 (0)