{"record":{"id":"f63d68fdfb787140","repo":"apache/druid","slug":"value-is-not-an-array-got-s-instead","errorCode":null,"errorMessage":"Value is not an array, got [%s] instead","messagePattern":"Value is not an array, got \\[(.+?)\\] instead","errorType":"exception","errorClass":"org.apache.druid.java.util.common.ISE","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/nested/VariantArrayFieldColumnWriter.java","lineNumber":73,"sourceCode":"          globalIds[i] = globalDictionaryIdLookup.lookupString((String) array[i]);\n        } else if (array[i] instanceof Long) {\n          globalIds[i] = globalDictionaryIdLookup.lookupLong((Long) array[i]);\n        } else if (array[i] instanceof Double) {\n          globalIds[i] = globalDictionaryIdLookup.lookupDouble((Double) array[i]);\n        } else {\n          globalIds[i] = -1;\n        }\n        Preconditions.checkArgument(globalIds[i] >= 0, \"unknown global id [%s] for value [%s]\", globalIds[i], array[i]);\n        arrayElements.computeIfAbsent(\n            globalIds[i],\n            (id) -> columnFormatSpec.getBitmapEncoding().getBitmapFactory().makeEmptyMutableBitmap()\n        ).add(row);\n      }\n      return globalIds;\n    }\n    if (value != null) {\n      // this writer is only used for arrays so all values will have been coerced to Object[] at this point\n      throw new ISE(\"Value is not an array, got [%s] instead\", value.getClass());\n    }\n    return null;\n  }\n\n  @Override\n  int lookupGlobalId(int[] value)\n  {\n    return globalDictionaryIdLookup.lookupArray(value);\n  }\n}\n","sourceCodeStart":55,"sourceCodeEnd":84,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/nested/VariantArrayFieldColumnWriter.java#L55-L84","documentation":"This error is thrown by VariantArrayFieldColumnWriter.processValue when a value passed to the nested-field array writer is not an Object[]. The writer is only used for array-typed fields, and upstream coercion is supposed to guarantee that every non-null value is an Object[] before reaching this point; encountering anything else means an internal type invariant was violated.","triggerScenarios":"Writing a nested variant column where a row value for an array field was not coerced to Object[] (e.g. a scalar or null-wrapped value slipped through the coercion in the nested field indexer), or calling processValue directly with a non-array value.","commonSituations":"Custom or patched ingestion code feeding raw values into the nested column writer; Druid version changes where coercion behavior for mixed-type array fields changed; segment generation during ingestion of JSON with an array field whose elements were flattened or mistyped.","solutions":["Inspect the input data at the failing row and confirm the array field actually contains arrays at ingestion","Ensure values pass through the standard nested-field coercion path (FieldTypeInfo/coercion to Object[]) before writing","Upgrade Druid to a version with the latest nested-column coercion fixes","File a bug with the failing input row if standard ingestion triggers this"],"exampleFix":"// before\nwriter.processValue(someScalar);\n// after\nif (!(value instanceof Object[])) { value = value == null ? null : new Object[]{value}; }\nwriter.processValue((Object[]) value);","handlingStrategy":"type-guard","validationCode":"if (value != null && !(value instanceof Object[])) { throw new IllegalArgumentException(\"expected array, got \" + value.getClass()); }","typeGuard":"static boolean isArrayValue(Object v) { return v instanceof Object[]; }","tryCatchPattern":"try { writer.processValue(v); } catch (IllegalStateException e) { if (e.getMessage().startsWith(\"Value is not an array\")) { /* coerce or skip row */ } else { throw e; } }","preventionTips":["Always funnel nested-field values through ExprEval/StructuredData coercion before writing","Log the offending row's class when debugging ingestion","Keep nested-column coercion code paths unchanged across upgrades unless tested"],"tags":["druid","segment-writing","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}