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 AbstractDebuggerVariableViewerVarValue when a value string begins with '{' (signaling a byte-array/hex literal) but does not end with '}'. Byte-array values must be fully braced; the parser refuses a dangling opening brace.

Source

Thrown at Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/variable/AbstractDebuggerVariableViewerVarValue.java:177

			return "{ " + NumericUtilities.convertBytesToString(value, 0, 64, " ") + " ... }";
		}
		return "{ " + NumericUtilities.convertBytesToString(value, " ") + " }";
	}

	public void setValue(String valueString) {
		if ((value == null) || (language == null)) {
			throw new AssertionError("Value and language cannot be null");
		}
		if ((getDataType() == null) || (value == null)) {
			// isValueEditable should have been false
			Msg.error(this, "No value or no data type");
			return;
		}

		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);
	}

	private void setRawValueBytesString(String bytesString) {
		setRawValueBytes(NumericUtilities.convertStringToBytes(bytesString));
	}

	private 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

  1. Complete the byte-array literal with a closing brace, e.g., '{deadbeef}'.
  2. If entering a scalar/integer value, do not prefix with '{'.
  3. Validate the input in the UI: a leading '{' must pair with a trailing '}'.
  4. Strip stray braces from pasted content before submission.

Example fix

// before
setRawValueString("{deadbeef"); // missing closing brace -> NumberFormatException

// after
setRawValueString("{deadbeef}"); // well-formed byte-array literal
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 {
    varValue.setRawValueString(s);
} catch (NumberFormatException e) {
    showError("Unmatched '{': byte arrays must be hex enclosed in {}");
}

Prevention

When it happens

Trigger: User enters a value string starting with '{' but missing the closing '}' in the Variables viewer value field.

Common situations: Typo or partial paste of a byte-array literal (e.g., '{deadbeef'); forgetting to close the brace; copy-paste truncation.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/3a7340fbef7427ab. Report an issue: GitHub.