{"record":{"id":"a28a0db9d9a1dc1d","repo":"pentaho/pentaho-kettle","slug":"avroinput-error-unexpectedrecordfieldtypeatnonexpansionpoint","errorCode":null,"errorMessage":"AvroInput.Error.UnexpectedRecordFieldTypeAtNonExpansionPoint","messagePattern":"AvroInput\\.Error\\.UnexpectedRecordFieldTypeAtNonExpansionPoint","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/avro-format/core/src/main/java/org/pentaho/di/trans/steps/avro/input/AvroNestedReader.java","lineNumber":1407,"sourceCode":"            Object[][] result = new Object[ 1 ][ m_outputRowMeta.size() + RowDataUtil.OVER_ALLOCATE_SIZE ];\n            return result;\n          }\n        }\n      }\n\n      // what have we got?\n      if ( fieldT == Schema.Type.RECORD ) {\n        return convertToKettleValues( (GenericData.Record) field, fieldSchema, defaultSchema, space, ignoreMissing );\n      } else if ( fieldT == Schema.Type.ARRAY ) {\n        return convertToKettleValues( (GenericData.Array) field, fieldSchema, defaultSchema, space, ignoreMissing );\n      } else if ( fieldT == Schema.Type.MAP ) {\n\n        return convertToKettleValues( (Map<Utf8, Object>) field, fieldSchema, defaultSchema, space, ignoreMissing );\n      } else {\n        // primitives will always be handled by the subField delegates, so we\n        // should'nt\n        // get here\n        throw new KettleException( BaseMessages.getString( PKG,\n          \"AvroInput.Error.UnexpectedRecordFieldTypeAtNonExpansionPoint\" ) );\n      }\n    }\n  }\n\n  // ----------------- End AvroArrayExpansion inner class --------------------------------\n\n  /**\n   * Converts an incoming row to outgoing format. Extracts fields from either an Avro object in the incoming row or from\n   * the next structure in the container or non-container Avro file. May return more than one row if a map/array is\n   * being expanded.\n   *\n   * @param incoming incoming kettle row - may be null if decoding from a file rather than a field\n   * @param space    the variables to use\n   * @return one or more rows in the outgoing format\n   * @throws KettleException if a problem occurs\n   */\n  public Object[][] avroObjectToKettle( Object[] incoming, VariableSpace space ) throws KettleException {","sourceCodeStart":1389,"sourceCodeEnd":1425,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/avro-format/core/src/main/java/org/pentaho/di/trans/steps/avro/input/AvroNestedReader.java#L1389-L1425","documentation":"At a non-expansion point the resolved field type was neither RECORD, ARRAY nor MAP — i.e. a primitive was encountered where a nested structure was required to continue path traversal. Primitives are handled by sub-field delegates, so reaching this branch is an invariant violation and AvroNestedReader throws this KettleException.","triggerScenarios":"In AvroArrayExpansion.convertToKettleValues, the field's effective Schema.Type (after union unwrapping) is a primitive (STRING, INT, etc.) while remaining path segments still expect a nested container.","commonSituations":"Configured paths assume nesting (record.array.field) but the actual schema has a scalar at that level; schema evolution replaced a nested structure with a primitive; wrong schema version loaded.","solutions":["Fix the path definition to stop at the primitive field; let a sub-field delegate read it.","Regenerate/verify the schema so it matches the data's actual nesting.","Check that the correct schema (not an older/newer version) is supplied to the step.","Test the step with a sample record to confirm path/schema alignment."],"exampleFix":"// before: path expects nested object\n$.order.items[0].sku\n// after: items is now a primitive string id\n$.order.items","handlingStrategy":"validation","validationCode":"Schema.Type t = resolveType(schema, pathSegments);\nif (!EnumSet.of(Schema.Type.RECORD, Schema.Type.ARRAY, Schema.Type.MAP).contains(t)) {\n  throw new IllegalStateException(\"path traverses into primitive: \" + t);\n}","typeGuard":null,"tryCatchPattern":"try {\n  rows = reader.avroObjectToKettle(row, space);\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"UnexpectedRecordFieldTypeAtNonExpansionPoint\")) { routeToErrorStream(row, e); } else throw e;\n}","preventionTips":["Design paths to stop at primitives; let sub-field delegates read leaves.","Re-validate paths whenever the schema changes."],"tags":["avro","schema","path","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}