{"record":{"id":"2cc726357a752c32","repo":"pentaho/pentaho-kettle","slug":"the-function-call-removecrlf-is-not-valid","errorCode":null,"errorMessage":"The function call removeCRLF is not valid","messagePattern":"The function call removeCRLF is not valid","errorType":"exception","errorClass":"Rhino runtime error","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":2877,"sourceCode":"    } else {\n      throw Context.reportRuntimeError( \"The function call getOcuranceString is not valid\" );\n    }\n    return nr;\n  }\n\n  public static String removeCRLF( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    if ( ArgList.length == 1 ) {\n      try {\n        if ( isNull( ArgList[0] ) ) {\n          return null;\n        } else if ( isUndefined( ArgList[0] ) ) {\n          return (String) Context.getUndefinedValue();\n        }\n\n        return Const.removeCRLF( Context.toString( ArgList[0] ) );\n      } catch ( Exception e ) {\n        throw Context.reportRuntimeError( \"The function call removeCRLF is not valid\" );\n      }\n    } else {\n      throw Context.reportRuntimeError( \"The function call removeCRLF is not valid\" );\n    }\n  }\n}\n","sourceCodeStart":2859,"sourceCodeEnd":2884,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L2859-L2884","documentation":"removeCRLF() wraps its logic in a try/catch; if Const.removeCRLF or argument conversion throws, a generic 'The function call removeCRLF is not valid' Rhino runtime error is reported. This is the exception branch of the function.","triggerScenarios":"removeCRLF(value) is called with an argument present but whose conversion to a Java String throws (unusual Rhino wrapper objects, NativeJavaObject issues).","commonSituations":"Passing a Java object from a previous step rather than a string, or corrupted row values.","solutions":["Coerce the argument to a JS string first: removeCRLF(String(value)).","Inspect the row field type feeding the script.","Use a Select values step to convert the field to String before the Script step."],"exampleFix":"// before\nvar clean = removeCRLF(someJavaObject);\n// after\nvar clean = removeCRLF(String(someJavaObject));","handlingStrategy":"type-guard","validationCode":"// JS\nif (value == null) value = '';","typeGuard":"function isStr(v){ return typeof v === 'string'; }","tryCatchPattern":"try { var clean = removeCRLF(String(value)); } catch (e) { /* fallback */ }","preventionTips":["Convert fields to String upstream (Select values step).","Never pass raw Java objects into the JS string helpers."],"tags":["javascript","kettle","rhino","argument"],"backgroundTag":"invalid-argument","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"}