{"record":{"id":"2ce3676383d0a900","repo":"apache/beam","slug":"invalid-hexadecimal-snowflake-binary-value","errorCode":null,"errorMessage":"Invalid hexadecimal Snowflake binary value.","messagePattern":"Invalid hexadecimal Snowflake binary value\\.","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/snowflake/src/main/java/org/apache/beam/sdk/io/snowflake/SnowflakeSchemaTransformUtils.java","lineNumber":272,"sourceCode":"        case ITERABLE:\n        case MAP:\n        case ROW:\n        case LOGICAL_TYPE:\n        default:\n          throw unsupportedFieldType(field, null);\n      }\n    } catch (IllegalArgumentException e) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Unable to parse value '%s' as %s for Snowflake field '%s'.\",\n              value, field.getType().getTypeName(), field.getName()),\n          e);\n    }\n  }\n\n  private static byte[] decodeHex(String value) {\n    if ((value.length() & 1) != 0) {\n      throw new IllegalArgumentException(\"Invalid hexadecimal Snowflake binary value.\");\n    }\n\n    byte[] result = new byte[value.length() / 2];\n\n    for (int i = 0; i < value.length(); i += 2) {\n      int high = Character.digit(value.charAt(i), 16);\n      int low = Character.digit(value.charAt(i + 1), 16);\n\n      if (high == -1 || low == -1) {\n        throw new IllegalArgumentException(\"Invalid hexadecimal Snowflake binary value.\");\n      }\n\n      result[i / 2] = (byte) ((high << 4) | low);\n    }\n\n    return result;\n  }\n","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/snowflake/src/main/java/org/apache/beam/sdk/io/snowflake/SnowflakeSchemaTransformUtils.java#L254-L290","documentation":"decodeHex converts a Snowflake binary value given as a hexadecimal string into bytes. If the hex string has an odd number of characters it cannot map to whole bytes, so it immediately throws an IllegalArgumentException.","triggerScenarios":"A BYTES-typed field whose Snowflake value is a hex string with odd length (e.g. \"abc\"), typically from truncated or hand-edited values.","commonSituations":"Truncated hex during export/copy; manual data edits dropping a character; misconfigured export that strips leading zeros.","solutions":["Regenerate/export the value ensuring even-length hex (e.g. HEX_ENCODE with correct settings).","Left-pad the hex string with a leading '0' if the odd length is due to a dropped leading zero.","Catch IllegalArgumentException around toRow and route the bad row to a dead-letter path."],"exampleFix":"// before\nbyte[] bytes = toRow(new String[]{\"abc\"}, schema); // odd-length hex\n// after\nbyte[] bytes = toRow(new String[]{\"0abc\"}, schema); // padded to even length","handlingStrategy":"validation","validationCode":"if (value == null || value.length() % 2 != 0 || !value.matches(\"[0-9a-fA-F]+\")) {\n  throw new IllegalArgumentException(\"not valid hex: \" + value);\n}","typeGuard":null,"tryCatchPattern":"try { Row r = SnowflakeSchemaTransformUtils.toRow(parts, schema); }\ncatch (IllegalArgumentException e) { deadLetter(parts, e); }","preventionTips":["Validate hex strings (even length, [0-9a-fA-F]) before the pipeline runs.","Ensure exports do not truncate or strip leading zeros.","Add checksum verification when copying binary data between systems."],"tags":["java","snowflake","hex","binary"],"backgroundTag":"invalid-argument-format","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}