{"record":{"id":"8707d3a7256e432f","repo":"pentaho/pentaho-kettle","slug":"sortrowsmeta-checkresult-stepfieldnotininputstream","errorCode":"SortRowsMeta.CheckResult.StepFieldNotInInputStream","errorMessage":"SortRowsMeta.CheckResult.StepFieldNotInInputStream","messagePattern":"SortRowsMeta\\.CheckResult\\.StepFieldNotInInputStream","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/sort/SortRows.java","lineNumber":420,"sourceCode":"            return false;\n          }\n        }\n      }\n\n      String[] fieldNames = meta.getFieldName();\n      data.fieldnrs = new int[fieldNames.length];\n      List<Integer> toConvert = new ArrayList<Integer>();\n\n      // Metadata\n      data.outputRowMeta = inputRowMeta.clone();\n      meta.getFields( getTransMeta().getBowl(), data.outputRowMeta, getStepname(), null, null, this, repository,\n        metaStore );\n      data.comparator = new RowTemapFileComparator( data.outputRowMeta, data.fieldnrs );\n\n      for ( int i = 0; i < fieldNames.length; i++ ) {\n        data.fieldnrs[i] = inputRowMeta.indexOfValue( fieldNames[i] );\n        if ( data.fieldnrs[i] < 0 ) {\n          throw new KettleException( BaseMessages.getString( PKG, \"SortRowsMeta.CheckResult.StepFieldNotInInputStream\",\n              meta.getFieldName()[i], getStepname() ) );\n        }\n        // do we need binary conversion for this type?\n        if ( inputRowMeta.getValueMeta( data.fieldnrs[i] ).isStorageBinaryString() ) {\n          toConvert.add( data.fieldnrs[i] );\n        }\n      }\n      data.convertKeysToNative = toConvert.isEmpty() ? null : new int[toConvert.size()];\n      int i = 0;\n      for ( Integer in : toConvert ) {\n        data.convertKeysToNative[i] = in;\n        i++;\n      }\n      data.rowComparator = new RowObjectArrayComparator( data.outputRowMeta, data.fieldnrs );\n    } // end if first\n\n    // it is not first row and it is null\n    if ( r == null ) {","sourceCodeStart":402,"sourceCodeEnd":438,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/sort/SortRows.java#L402-L438","documentation":"During SortRows.processRow() initialization, each configured sort field is looked up by name in the incoming row metadata. If indexOfValue() returns -1 the step cannot sort, so it throws a KettleException using the SortRowsMeta.CheckResult.StepFieldNotInInputStream message, naming the missing field and step.","triggerScenarios":"A field name configured in the Sort rows step does not exist in the row arriving at runtime — typically because an upstream step was changed/removed, field names are case-mismatched, or the hop delivering the row differs from the design-time preview.","commonSituations":"Renaming a column upstream (e.g., in Select values) without updating Sort rows; streams where fields appear only conditionally; whitespace differences in the field name; switching the primary input hop.","solutions":["Open the Sort rows step and re-select field names from the current upstream field list (delete and re-add stale entries).","Check exact case and whitespace of the field name vs upstream output.","Use 'Get Fields' in the step dialog after the upstream step is finalized.","Preview the input row (right-click step > Preview) to confirm which fields actually arrive.","Fix upstream steps that conditionally drop or rename the field."],"exampleFix":"// before\nsortField[0] = \"CUSTOMER ID\"; // upstream field is 'CUSTOMER_ID'\n// after\nsortField[0] = \"CUSTOMER_ID\";","handlingStrategy":"validation","validationCode":"for (String f : meta.getFieldName()) {\n  if (inputRowMeta.indexOfValue(f) < 0) {\n    throw new IllegalArgumentException(\"Sort field not in stream: \" + f);\n  }\n}","typeGuard":null,"tryCatchPattern":"try { trans.execute(new String[0]); } catch (KettleException e) {\n  if (e.getMessage().contains(\"field\") && e.getMessage().contains(\"row\")) {\n    logError(\"Sort field missing from input: \" + e.getMessage());\n  }\n}","preventionTips":["Use 'Get Fields' in the Sort dialog after upstream steps are final.","Re-validate transformations after renaming upstream fields.","Preview input rows before production runs.","Avoid conditional upstream steps that drop sort keys."],"tags":["kettle","sort","missing-field","row-metadata"],"backgroundTag":"record-not-found","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"}