NationalSecurityAgency/ghidra · error · NumberFormatException
Byte array values must be hex enclosed in {}
Error message
Byte array values must be hex enclosed in {} What it means
Thrown by DefaultWatchRow.setRawValueString when a value string begins with '{' (byte-array hex literal) but lacks the closing '}'. Identical grammar rule to the Variables viewer: brace-delimited hex is the only accepted byte-array syntax.
Source
Thrown at Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/DefaultWatchRow.java:433
}
DebuggerControlService controlService = provider.controlService;
if (controlService == null) {
return false;
}
StateEditor editor = controlService.createStateEditor(provider.current);
return editor.isVariableEditable(address, getValueLength());
}
}
@Override
public void setRawValueString(String valueString) {
if (!isRawValueEditable()) {
throw new IllegalStateException("Watch is not editable");
}
valueString = valueString.trim();
if (valueString.startsWith("{")) {
if (!valueString.endsWith("}")) {
throw new NumberFormatException("Byte array values must be hex enclosed in {}");
}
setRawValueBytesString(valueString.substring(1, valueString.length() - 1));
return;
}
setRawValueIntString(valueString);
}
public void setRawValueBytesString(String bytesString) {
setRawValueBytes(NumericUtilities.convertStringToBytes(bytesString));
}
public void setRawValueIntString(String intString) {
intString = intString.trim();
final BigInteger val;
if (intString.startsWith("0x")) {
val = new BigInteger(intString.substring(2), 16);View on GitHub (pinned to d5f144c24d)
Solutions
- Close the byte-array literal with '}', e.g., '{cafebabe}'.
- For scalar integers, omit the braces and use plain decimal or 0x-hex.
- Add a UI validator that enforces brace pairing before calling setRawValueString.
- Trim whitespace and check first/last character before parsing.
Example fix
// before
row.setRawValueString("{cafe"); // unterminated -> NumberFormatException
// after
row.setRawValueString("{cafe}"); Defensive patterns
Strategy: validation
Validate before calling
String s = valueString.trim();
boolean wellFormed = !s.startsWith("{") || s.endsWith("}"); Type guard
static boolean wellFormedByteArray(String s) {
s = s.trim();
return !s.startsWith("{") || s.endsWith("}");
} Try / catch
try {
row.setRawValueString(s);
} catch (NumberFormatException e) {
showError("Byte arrays must be hex enclosed in {}");
} Prevention
- Validate watch input braces before parsing.
- Use plain hex/decimal for scalars.
When it happens
Trigger: User edits a Watch row value with a string starting in '{' that is not terminated by '}'.
Common situations: Typo in the Watches window; partial paste; intending a scalar but accidentally prefixing with '{'.
Related errors
- Byte array values must be hex enclosed in {}
- Byte arrays cannot exceed length of variable
- Bad nodeSize: {}
- Invalid number of elements specified: {}
- Unable to read {} bytes
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/0090d9a0b9563eca.
Report an issue: GitHub.