{"record":{"id":"0cfa9904399f333c","repo":"elastic/elasticsearch","slug":"cannot-convert-object-of-type-to-bytes","errorCode":null,"errorMessage":"cannot convert object of type [{}] to bytes","messagePattern":"cannot convert object of type \\[(.+?)\\] to bytes","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/FingerprintProcessor.java","lineNumber":190,"sourceCode":"            ByteUtils.writeIntLE(zdt.getMonthValue(), zdtBytes, 4);\n            ByteUtils.writeIntLE(zdt.getDayOfMonth(), zdtBytes, 8);\n            ByteUtils.writeIntLE(zdt.getHour(), zdtBytes, 12);\n            ByteUtils.writeIntLE(zdt.getMinute(), zdtBytes, 16);\n            ByteUtils.writeIntLE(zdt.getSecond(), zdtBytes, 20);\n            ByteUtils.writeIntLE(zdt.getNano(), zdtBytes, 24);\n            ByteUtils.writeIntLE(zdt.getOffset().getTotalSeconds(), zdtBytes, 28);\n            System.arraycopy(zoneIdBytes, 0, zdtBytes, 32, zoneIdBytes.length);\n            return zdtBytes;\n        }\n        if (value instanceof Date date) {\n            byte[] dateBytes = new byte[8];\n            ByteUtils.writeLongLE(date.getTime(), dateBytes, 0);\n            return dateBytes;\n        }\n        if (value == null) {\n            return new byte[0];\n        }\n        throw new IllegalArgumentException(\"cannot convert object of type [\" + value.getClass().getName() + \"] to bytes\");\n    }\n\n    public List<String> getFields() {\n        return fields;\n    }\n\n    public String getTargetField() {\n        return targetField;\n    }\n\n    public ThreadLocal<Hasher> getThreadLocalHasher() {\n        return threadLocalHasher;\n    }\n\n    public byte[] getSalt() {\n        return salt;\n    }\n","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/FingerprintProcessor.java#L172-L208","documentation":"Thrown by FingerprintProcessor.toBytes when the field value is of a Java type the static toBytes helper does not handle. Supported types: String, byte[], Integer, Long, Float, Double, Boolean, ZonedDateTime, Date, and null (null yields empty bytes). Any other type (e.g. a nested List, Map, ArrayList of mixed objects, BigDecimal, or a custom ingest metadata type) reaches the final throw, naming the runtime class.","triggerScenarios":"Configuring the fingerprint processor on a field that contains an array/object (List or Map) or an unsupported scalar like BigDecimal. The per-field traversal pushes list elements individually, but a value that is itself a non-supported scalar or a Map hits this branch.","commonSituations":"Field selection mistakes (pointing at nested objects rather than leaf scalars); JSON arrays of objects; BigDecimal/BigInteger values produced by upstream processors; objects inserted by enrichment processors; selecting a field that holds the entire document.","solutions":["Select only leaf scalar fields (string, number, boolean, date) in the 'fields' list.","For nested values, use a script processor to extract and flatten them into scalar fields before fingerprinting.","Convert unsupported numerics to string with a preceding convert processor (type 'string').","If a field legitimately contains arrays of scalars, ensure they are flattened first; Maps cannot be hashed by this processor."],"exampleFix":"// before - field \"tags\" is a Map / object, fingerprint rejects it\n{\"fingerprint\": {\"fields\": [\"id\", \"tags\"]}}\n// after - flatten or stringify first\n{\"convert\": {\"field\": \"tags\", \"type\": \"string\", \"ignore_missing\": true}},\n{\"fingerprint\": {\"fields\": [\"id\", \"tags\"]}}","handlingStrategy":"type-guard","validationCode":"// Convert non-string scalars to string before fingerprint, and avoid pointing at objects:\n{\"convert\": {\"field\": \"amount\", \"type\": \"string\", \"ignore_missing\": true}}","typeGuard":"// painless - verify each selected field is a leaf scalar\nboolean isHashable(def v) { return v == null || v instanceof String || v instanceof Number || v instanceof Boolean || v instanceof ZonedDateTime || v instanceof JodaCompatibleZonedDateTime; }","tryCatchPattern":"{\"on_failure\": [{\"index\": {\"index\": \"ingest-dlq\"}}]}","preventionTips":["Select only leaf scalar fields in fingerprint.fields.","Flatten nested objects with a script processor before fingerprinting.","Convert BigDecimal/BigInteger or unsupported types to string first."],"tags":["ingest","fingerprint-processor","type-coercion","config"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}