{"record":{"id":"08f6e30976aed20f","repo":"pentaho/pentaho-kettle","slug":"gpload-exception-maxerrorsinvalid","errorCode":null,"errorMessage":"GPLoad.Exception.MaxErrorsInvalid","messagePattern":"GPLoad\\.Exception\\.MaxErrorsInvalid","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/gpload/core/src/main/java/org/pentaho/di/trans/steps/gpload/GPLoad.java","lineNumber":317,"sourceCode":"    contents.append( GPLoad.INDENT ).append( \"- QUOTE: \" ).append( GPLoad.SINGLE_QUOTE ).append( enclosure ).append(\n        GPLoad.SINGLE_QUOTE ).append( Const.CR );\n    contents.append( GPLoad.INDENT ).append( \"- HEADER: FALSE\" ).append( Const.CR );\n\n    // ENCODING\n    String encoding = meta.getEncoding();\n    if ( !Utils.isEmpty( encoding ) ) {\n      contents.append( GPLoad.INDENT ).append( \"- ENCODING: \" ).append( encoding ).append( Const.CR );\n    }\n\n    // Max errors\n    String maxErrors = meta.getMaxErrors();\n    if ( maxErrors == null ) {\n      maxErrors = GPLoadMeta.MAX_ERRORS_DEFAULT;\n    } else {\n      maxErrors = environmentSubstitute( maxErrors );\n      try {\n        if ( Integer.valueOf( maxErrors ) < 0 ) {\n          throw new KettleException( BaseMessages.getString( PKG, \"GPLoad.Exception.MaxErrorsInvalid\" ) );\n        }\n      } catch ( NumberFormatException nfe ) {\n        throw new KettleException( BaseMessages.getString( PKG, \"GPLoad.Exception.MaxErrorsInvalid\" ) );\n      }\n    }\n\n    contents.append( GPLoad.INDENT ).append( \"- ERROR_LIMIT: \" ).append( maxErrors ).append( Const.CR );\n\n    String errorTableName = meta.getErrorTableName();\n    if ( !Utils.isEmpty( errorTableName ) ) {\n      errorTableName = environmentSubstitute( errorTableName ).trim();\n      if ( !Utils.isEmpty( errorTableName ) ) {\n        contents.append( GPLoad.INDENT ).append( \"- ERROR_TABLE: \" ).append( errorTableName ).append( Const.CR );\n      }\n    }\n\n    // -------------- OUTPUT section\n","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/gpload/core/src/main/java/org/pentaho/di/trans/steps/gpload/GPLoad.java#L299-L335","documentation":"GPLoad validates the ERROR_LIMIT (max errors) setting while emitting the control file. If the value parses as an integer but is negative, this exception is thrown because gpload's ERROR_LIMIT must be >= 0.","triggerScenarios":"getControlFileContents called with meta.getMaxErrors() non-null, environment-substituted, and Integer.valueOf(maxErrors) < 0.","commonSituations":"User typed -1 intending 'unlimited'; an environment variable like ${MAX_ERRORS} resolves to a negative number; pasted value with a minus sign by mistake.","solutions":["Set Max Errors to a non-negative integer (0 typically means unlimited for gpload) in the step dialog.","Check the value of any ${MAX_ERRORS}-style environment variable at runtime.","Correct the value in kettle.properties or the job variable configuration.","Programmatically use meta.setMaxErrors(\"0\") or a positive count."],"exampleFix":"// before\nmeta.setMaxErrors(\"-1\"); // throws GPLoad.Exception.MaxErrorsInvalid\n// after\nmeta.setMaxErrors(\"0\"); // 0 = unlimited, or e.g. \"100\"","handlingStrategy":"validation","validationCode":"String maxErrors = meta.getMaxErrors();\ntry {\n  if (maxErrors != null && Integer.parseInt(maxErrors.trim()) < 0) {\n    throw new IllegalArgumentException(\"Max errors must be >= 0\");\n  }\n} catch (NumberFormatException nfe) {\n  throw new IllegalArgumentException(\"Max errors must be an integer\", nfe);\n}","typeGuard":null,"tryCatchPattern":"try {\n  step.createControlFile(meta);\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"MaxErrorsInvalid\")) { /* reset Max Errors to a valid integer */ }\n  else throw e;\n}","preventionTips":["Enter plain non-negative integers only; use 0 for unlimited.","Never use -1 as a sentinel in this field.","If driven by a variable, validate the variable value in a prior step.","Test the dialog's YAML output after changing numeric fields."],"tags":["kettle","gpload","greenplum","validation","numeric"],"backgroundTag":"invalid-argument-value","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"}