apache/cassandra · error · InvalidRequestException
In call to function %s, value 0x%s is not a valid binary rep
Error message
In call to function %s, value 0x%s is not a valid binary representation for type %s
What it means
Thrown by the blob conversion functions (BytesConversionFcts) when validating that a raw blob is a valid binary representation of the target type. If toType.validate throws MarshalException, the call is rejected with InvalidRequestException instead of returning garbage.
Source
Thrown at src/java/org/apache/cassandra/cql3/functions/BytesConversionFcts.java:120
toType.getType().udfType(),
BytesType.instance);
this.toType = toType;
}
@Override
public ByteBuffer execute(Arguments arguments)
{
ByteBuffer val = arguments.get(0);
if (val != null)
{
try
{
toType.getType().validate(val);
}
catch (MarshalException e)
{
throw new InvalidRequestException(String.format("In call to function %s, value 0x%s is not a " +
"valid binary representation for type %s",
name, ByteBufferUtil.bytesToHex(val), toType));
}
}
return val;
}
@Override
public NativeFunction withLegacyName()
{
return new FromBlobFunction(toType, true);
}
}
}
View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Ensure the blob was produced by the matching *asblob function for the target type.
- Check the hex literal length matches the type's serialized size (int=4 bytes, bigint=8, uuid=16).
- If the type changed, migrate data via a correct re-serialization rather than a direct blob cast.
Example fix
// before: SELECT intastext(some_blob_col) ... where blob holds a 16-byte UUID // after SELECT uuidastext(some_blob_col) ... -- use the conversion matching the actual type
Defensive patterns
Strategy: validation
Validate before calling
// Java: verify size before conversion
// int blob must be 4 bytes, bigint 8, uuid 16
if (val.remaining() != 4) throw new IllegalArgumentException("expected 4-byte int blob"); Try / catch
catch (InvalidRequestException e) { if (e.getMessage().contains("not a valid binary representation")) { log.warn("blob/type mismatch"); } } Prevention
- Only feed blobs produced by the matching *asblob function.
- Track the original type of blob columns in metadata.
- Check serialized sizes per type before conversion.
When it happens
Trigger: Calling conversion functions like blobastext, textasblob, intasblob, or the generic blob-to-type function with bytes that fail the target type's validation (wrong byte count for fixed-size types, invalid encoding).
Common situations: Reinterpreting a blob produced for one type as another type (e.g. a 4-byte int blob passed where a UUID is expected); hand-crafted hex literals with wrong length; deserializing columns after a schema type change.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- <id> is not a valid Transformation.Kind id
- none of the arguments may be null
- value must be non-negative
- category %s not found in %s
- GRANT operation is not supported by AllowAllAuthorizer
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/a4ff8504f7029a89.
Report an issue: GitHub.