{"record":{"id":"e7485f8ccd038aed","repo":"pentaho/pentaho-kettle","slug":"avroinput-error-incommingschemaismissingandnodefault","errorCode":null,"errorMessage":"AvroInput.Error.IncommingSchemaIsMissingAndNoDefault","messagePattern":"AvroInput\\.Error\\.IncommingSchemaIsMissingAndNoDefault","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":1622,"sourceCode":"  }\n\n  public void close() throws IOException {\n    if ( m_containerReader != null ) {\n      m_containerReader.close();\n    }\n    if ( m_inStream != null ) {\n      m_inStream.close();\n    }\n\n  }\n\n  protected void setSchemaToUse( String schemaKey, boolean useCache, VariableSpace space ) throws KettleException {\n\n    if ( Const.isEmpty( schemaKey ) ) {\n      // switch to default\n      if ( m_defaultDatumReader == null ) {\n        // no key, no default schema - can't continue with this row\n        throw new KettleException( BaseMessages.getString( PKG,\n          \"AvroInput.Error.IncommingSchemaIsMissingAndNoDefault\" ) );\n      }\n      if ( m_log.isDetailed() ) {\n        m_log.logDetailed( BaseMessages.getString( PKG, \"AvroInput.Message.IncommingSchemaIsMissing\" ) );\n      }\n      m_datumReader = m_defaultDatumReader;\n      m_schemaToUse = m_datumReader.getSchema();\n      setTopLevelStructure( m_defaultTopLevelObject );\n      return;\n    } else {\n      schemaKey = schemaKey.trim();\n      schemaKey = space.environmentSubstitute( schemaKey );\n    }\n\n    Object[] cached = null;\n    if ( useCache ) {\n      cached = m_schemaCache.get( schemaKey );\n      if ( m_log.isDetailed() && cached != null ) {","sourceCodeStart":1604,"sourceCodeEnd":1640,"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#L1604-L1640","documentation":"In setSchemaToUse, if no incoming schema key is present on the row (empty schemaKey) the step falls back to its default datum reader; when that default was never initialized there is no schema to decode with, so the step throws this KettleException — the row cannot be processed at all.","triggerScenarios":"Step configured to take the schema from an incoming field ('schema from field'/cache mode), but the row's schema-key field is empty/null and m_defaultDatumReader is null (no default schema configured in the step).","commonSituations":"Upstream step failed to populate the schema field; wrong incoming field selected as the schema source; user assumed a default schema was set but left the default-schema option empty; first row arrives before any cached schema is stored.","solutions":["Configure a default Avro schema in the step so rows without a schema key can still be decoded.","Fix the upstream step/field so the schema-key field is populated for every row.","Verify the correct incoming field is selected as the schema source in the step settings.","Add a filter step before Avro Input to route rows with missing schema keys to an error/ignore stream."],"exampleFix":"// before: no default schema in step meta\nm_defaultDatumReader = null;\n// after: initialize default schema at step init\nm_defaultDatumReader = new GenericDatumReader<Object>(defaultSchema);","handlingStrategy":"validation","validationCode":"if (Const.isEmpty(row[schemaFieldIndex])) {\n  throw new IllegalArgumentException(\"schema key field is empty on incoming row\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  rows = reader.avroObjectToKettle(row, space);\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"IncommingSchemaIsMissingAndNoDefault\")) { routeToErrorStream(row, e); } else throw e;\n}","preventionTips":["Always configure a default schema when using schema-from-field mode.","Guarantee the upstream step populates the schema field on every row."],"tags":["avro","schema","configuration","missing-value"],"backgroundTag":"missing-required-config-field","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"}