{"record":{"id":"c3142ee09908ffb3","repo":"pentaho/pentaho-kettle","slug":"jobentrysetvariables-meta-unablesaverep","errorCode":null,"errorMessage":"JobEntrySetVariables.Meta.UnableSaveRep","messagePattern":"JobEntrySetVariables\\.Meta\\.UnableSaveRep","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/job/entries/setvariables/JobEntrySetVariables.java","lineNumber":214,"sourceCode":"  public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_job ) throws KettleException {\n    try {\n      rep.saveJobEntryAttribute( id_job, getObjectId(), \"replacevars\", replaceVars );\n\n      rep.saveJobEntryAttribute( id_job, getObjectId(), \"filename\", filename );\n      rep.saveJobEntryAttribute(\n        id_job, getObjectId(), \"file_variable_type\", getVariableTypeCode( fileVariableType ) );\n\n      // save the variableName...\n      if ( variableName != null ) {\n        for ( int i = 0; i < variableName.length; i++ ) {\n          rep.saveJobEntryAttribute( id_job, getObjectId(), i, \"variable_name\", variableName[i] );\n          rep.saveJobEntryAttribute( id_job, getObjectId(), i, \"variable_value\", variableValue[i] );\n          rep.saveJobEntryAttribute(\n            id_job, getObjectId(), i, \"variable_type\", getVariableTypeCode( variableType[i] ) );\n        }\n      }\n    } catch ( KettleDatabaseException dbe ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"JobEntrySetVariables.Meta.UnableSaveRep\", String\n        .valueOf( id_job ), dbe.getMessage() ), dbe );\n    }\n  }\n\n  public Result execute( Result result, int nr ) throws KettleException {\n    result.setResult( true );\n    result.setNrErrors( 0 );\n    try {\n\n      List<String> variables = new ArrayList<String>();\n      List<String> variableValues = new ArrayList<String>();\n      List<Integer> variableTypes = new ArrayList<Integer>();\n\n      String realFilename = environmentSubstitute( filename );\n      if ( !Utils.isEmpty( realFilename ) ) {\n        try ( InputStream is = KettleVFS.getInstance( parentJobMeta.getBowl() ).getInputStream( realFilename );\n            // for UTF8 properties files\n            InputStreamReader isr = new InputStreamReader( is, \"UTF-8\" );","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/job/entries/setvariables/JobEntrySetVariables.java#L196-L232","documentation":"This KettleException is thrown in saveRep when persisting the Set Variables entry's variable rows to the repository fails with a KettleDatabaseException. The message includes id_job and the DB error text, with the original exception as cause. It flags a repository write failure for this entry's variable_name/variable_value/variable_type attributes.","triggerScenarios":"Saving the job when rep.saveJobEntryAttribute throws for one of the variable rows: connection lost mid-loop, read-only DB, constraint violation, or null id_job/ObjectId.","commonSituations":"Network drop to repository DB while saving a job with many variables; DB account lacking write permission; duplicate/constraint issues after repository restore; saving from an unauthenticated repository session.","solutions":["Read the chained KettleDatabaseException and fix the DB issue (connectivity, locks, permissions)","Grant the repository user INSERT/UPDATE on R_JOBENTRY_ATTRIBUTE","Ensure the job entry is saved to the repository first (valid ObjectId) before attributes are written","Retry the save; if schema mismatch, run repository upgrade/repair tools"],"exampleFix":"// before\nentry.saveRep(rep, metaStore, idJob);\n// after\ntry {\n  entry.saveRep(rep, metaStore, idJob);\n} catch (KettleException e) {\n  logError(\"Save of Set Variables failed for job \" + idJob + \": \" + e.getMessage(), e);\n  // verify DB write access and ObjectId, then retry\n}","handlingStrategy":"try-catch","validationCode":"if (entry.getObjectId() == null) throw new IllegalStateException(\"Save the job entry to the repository first\");\nif (id_job == null) throw new IllegalArgumentException(\"id_job is null\");","typeGuard":null,"tryCatchPattern":"try {\n  entry.saveRep(rep, metaStore, idJob);\n} catch (KettleException e) {\n  logError(\"Repository save failed for job \" + id_job + \": \" + e.getMessage(), e);\n  // check DB write access, retry after recovery\n}","preventionTips":["Grant repository user INSERT/UPDATE on R_JOBENTRY_ATTRIBUTE","Avoid saving during DB maintenance windows or with read-only accounts","Save the job entry itself before its attribute rows","Run repository upgrade tools after PDI version upgrades"],"tags":["pdi","repository","persistence"],"backgroundTag":"database-write-failed","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"}