{"record":{"id":"c09d93d402ef3a31","repo":"apache/iceberg","slug":"not-a-list-type-this","errorCode":null,"errorMessage":"Not a list type: + this","messagePattern":"Not a list type: \\+ this","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/types/Type.java","lineNumber":81,"sourceCode":"    }\n  }\n\n  TypeID typeId();\n\n  default boolean isPrimitiveType() {\n    return false;\n  }\n\n  default PrimitiveType asPrimitiveType() {\n    throw new IllegalArgumentException(\"Not a primitive type: \" + this);\n  }\n\n  default Types.StructType asStructType() {\n    throw new IllegalArgumentException(\"Not a struct type: \" + this);\n  }\n\n  default Types.ListType asListType() {\n    throw new IllegalArgumentException(\"Not a list type: \" + this);\n  }\n\n  default Types.MapType asMapType() {\n    throw new IllegalArgumentException(\"Not a map type: \" + this);\n  }\n\n  default Types.VariantType asVariantType() {\n    throw new IllegalArgumentException(\"Not a variant type: \" + this);\n  }\n\n  default boolean isNestedType() {\n    return false;\n  }\n\n  default boolean isStructType() {\n    return false;\n  }\n","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/types/Type.java#L63-L99","documentation":"Type.asListType() narrows a Type to Types.ListType; the default throws IllegalArgumentException since non-list types do not override it. It indicates list-element access (elementType()) was requested on a type that is not a list.","triggerScenarios":"Calling asListType() on a struct, map, primitive, or variant — e.g. in visitor helpers (listType, elementType, listElementPartner) or when reading a list column whose field resolved to a different type.","commonSituations":"Handling nested element IDs where the referenced type is actually a map or struct; schema iteration code that assumes a field named 'element' is always a list; mapping Iceberg list columns to engine types incorrectly.","solutions":["Check type.isListType() before calling asListType().","Use a TypeVisitor to branch per type kind.","Fix ID/partner lookups so the element type is fetched from the actual list field."],"exampleFix":"// before\nTypes.ListType lt = field.type().asListType();\n// after\nif (field.type() instanceof Types.ListType) {\n  Types.ListType lt = (Types.ListType) field.type();\n}","handlingStrategy":"type-guard","validationCode":"Preconditions.checkArgument(type.isListType(), \"Expected list, got: %s\", type);","typeGuard":"if (type instanceof Types.ListType) {\n  Types.ListType lt = (Types.ListType) type;\n}","tryCatchPattern":"try {\n  Types.ListType lt = type.asListType();\n} catch (IllegalArgumentException e) {\n  // non-list path\n}","preventionTips":["Check isListType() before element access.","Fetch element types via the actual list field, not by ID/name assumptions.","Use TypeVisitor so each type kind is handled explicitly."],"tags":["types","iceberg","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}