Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions packages/suite-base/src/panels/RawMessages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,23 @@ function RawMessages(props: PropsRawMessages) {
if (rawVal == undefined) {
return rawVal;
}
const idValue = (rawVal as Record<string, unknown>)[diffLabels.ID.labelText];
const addedValue = (rawVal as Record<string, unknown>)[diffLabels.ADDED.labelText];
const changedValue = (rawVal as Record<string, unknown>)[

// react-json-tree treats typed arrays as opaque objects; convert them
// to regular arrays so users can expand and inspect element values.
const toDisplayValue =
ArrayBuffer.isView(rawVal) && !(rawVal instanceof DataView)
? Array.from(rawVal as unknown as ArrayLike<unknown>)
: rawVal;
const idValue = (toDisplayValue as Record<string, unknown>)[
diffLabels.ID.labelText
];
const addedValue = (toDisplayValue as Record<string, unknown>)[
diffLabels.ADDED.labelText
];
const changedValue = (toDisplayValue as Record<string, unknown>)[
diffLabels.CHANGED.labelText
];
const deletedValue = (rawVal as Record<string, unknown>)[
const deletedValue = (toDisplayValue as Record<string, unknown>)[
diffLabels.DELETED.labelText
];
if (
Expand All @@ -259,9 +270,12 @@ function RawMessages(props: PropsRawMessages) {
1 &&
idValue == undefined
) {
return addedValue ?? changedValue ?? deletedValue;
const unwrappedValue = addedValue ?? changedValue ?? deletedValue;
return ArrayBuffer.isView(unwrappedValue) && !(unwrappedValue instanceof DataView)
? Array.from(unwrappedValue as unknown as ArrayLike<unknown>)
: unwrappedValue;
}
return rawVal;
return toDisplayValue;
}}
theme={{
...jsonTreeTheme,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,10 @@ export const getValueActionForValue = (
// We currently don't support looking inside them.
return undefined;
} else {
throw new Error(
`Invalid structureType: ${state.structureItem?.structureType} for value/pathItem.`,
);
// Unexpected path/value/schema combinations can happen for synthetic keys
// (e.g. array internals). This path is only used for optional hover actions,
// so fail gracefully instead of crashing the panel.
return undefined;
}
}

Expand Down
Loading