{"record":{"id":"0090d9a0b9563eca","repo":"NationalSecurityAgency/ghidra","slug":"byte-array-values-must-be-hex-enclosed-in-0090d9","errorCode":null,"errorMessage":"Byte array values must be hex enclosed in {}","messagePattern":"Byte array values must be hex enclosed in (.+?)","errorType":"validation","errorClass":"NumberFormatException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/DefaultWatchRow.java","lineNumber":433,"sourceCode":"\t\t\t}\n\t\t\tDebuggerControlService controlService = provider.controlService;\n\t\t\tif (controlService == null) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tStateEditor editor = controlService.createStateEditor(provider.current);\n\t\t\treturn editor.isVariableEditable(address, getValueLength());\n\t\t}\n\t}\n\n\t@Override\n\tpublic void setRawValueString(String valueString) {\n\t\tif (!isRawValueEditable()) {\n\t\t\tthrow new IllegalStateException(\"Watch is not editable\");\n\t\t}\n\t\tvalueString = valueString.trim();\n\t\tif (valueString.startsWith(\"{\")) {\n\t\t\tif (!valueString.endsWith(\"}\")) {\n\t\t\t\tthrow new NumberFormatException(\"Byte array values must be hex enclosed in {}\");\n\t\t\t}\n\n\t\t\tsetRawValueBytesString(valueString.substring(1, valueString.length() - 1));\n\t\t\treturn;\n\t\t}\n\n\t\tsetRawValueIntString(valueString);\n\t}\n\n\tpublic void setRawValueBytesString(String bytesString) {\n\t\tsetRawValueBytes(NumericUtilities.convertStringToBytes(bytesString));\n\t}\n\n\tpublic void setRawValueIntString(String intString) {\n\t\tintString = intString.trim();\n\t\tfinal BigInteger val;\n\t\tif (intString.startsWith(\"0x\")) {\n\t\t\tval = new BigInteger(intString.substring(2), 16);","sourceCodeStart":415,"sourceCodeEnd":451,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/DefaultWatchRow.java#L415-L451","documentation":"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.","triggerScenarios":"User edits a Watch row value with a string starting in '{' that is not terminated by '}'.","commonSituations":"Typo in the Watches window; partial paste; intending a scalar but accidentally prefixing with '{'.","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."],"exampleFix":"// before\nrow.setRawValueString(\"{cafe\"); // unterminated -> NumberFormatException\n\n// after\nrow.setRawValueString(\"{cafe}\");","handlingStrategy":"validation","validationCode":"String s = valueString.trim();\nboolean wellFormed = !s.startsWith(\"{\") || s.endsWith(\"}\");","typeGuard":"static boolean wellFormedByteArray(String s) {\n    s = s.trim();\n    return !s.startsWith(\"{\") || s.endsWith(\"}\");\n}","tryCatchPattern":"try {\n    row.setRawValueString(s);\n} catch (NumberFormatException e) {\n    showError(\"Byte arrays must be hex enclosed in {}\");\n}","preventionTips":["Validate watch input braces before parsing.","Use plain hex/decimal for scalars."],"tags":["watch","bytes","user-input","parsing"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}