{"record":{"id":"3a92e14b7aa16a28","repo":"pentaho/pentaho-kettle","slug":"error-saving-condition-to-the-repository","errorCode":null,"errorMessage":"Error saving condition to the repository.","messagePattern":"Error saving condition to the repository\\.","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/repository/kdr/delegates/KettleDatabaseRepositoryConditionDelegate.java","lineNumber":110,"sourceCode":"        \"Error loading condition from the repository (id_condition=\" + id_condition + \")\", dbe );\n    }\n  }\n\n  public ObjectId saveCondition( Condition condition ) throws KettleException {\n    return saveCondition( condition, null );\n  }\n\n  public ObjectId saveCondition( Condition condition, ObjectId id_condition_parent ) throws KettleException {\n    try {\n      condition.setObjectId( insertCondition( id_condition_parent, condition ) );\n      for ( int i = 0; i < condition.nrConditions(); i++ ) {\n        Condition subc = condition.getCondition( i );\n        repository.saveCondition( subc, condition.getObjectId() );\n      }\n\n      return condition.getObjectId();\n    } catch ( KettleException dbe ) {\n      throw new KettleException( \"Error saving condition to the repository.\", dbe );\n    }\n  }\n\n  public synchronized ObjectId insertCondition( ObjectId id_condition_parent, Condition condition ) throws KettleException {\n    ObjectId id = repository.connectionDelegate.getNextConditionID();\n\n    String tablename = KettleDatabaseRepository.TABLE_R_CONDITION;\n    RowMetaAndData table = new RowMetaAndData();\n    table.addValue( new ValueMetaInteger(\n      KettleDatabaseRepository.FIELD_CONDITION_ID_CONDITION ), id );\n    table.addValue(\n      new ValueMetaInteger(\n        KettleDatabaseRepository.FIELD_CONDITION_ID_CONDITION_PARENT ),\n      id_condition_parent );\n    table.addValue( new ValueMetaBoolean(\n      KettleDatabaseRepository.FIELD_CONDITION_NEGATED ), Boolean\n      .valueOf( condition.isNegated() ) );\n    table.addValue( new ValueMetaString(","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/repository/kdr/delegates/KettleDatabaseRepositoryConditionDelegate.java#L92-L128","documentation":"Wrapper KettleException thrown by saveCondition when writing the condition (or its sub-conditions) to R_CONDITION fails. The original KettleException/database error is chained as cause. It wraps insert/update failures plus recursive saves of child conditions behind a uniform message.","triggerScenarios":"insertCondition or the update path throws (e.g., sequence/ID generation failure, constraint violation, connection loss), or a recursive repository.saveCondition(subCondition, parentId) fails.","commonSituations":"Repository DB out of disk space or read-only, lost connection mid-save, sequence R_CONDITION ID generator exhausted or missing, FK constraint issues.","solutions":["Check getCause() for the underlying database error","Verify repository database connectivity and writability (disk space, read-only mode)","Confirm the ID sequence/generator tables (R_REPOSITORY_LOG style sequences) are intact","Retry the save; if it persists, repair the repository schema with the provided upgrade/repair scripts"],"exampleFix":"// before\nconditionDelegate.saveCondition(condition); // may throw wrapped DB error\n\n// after\ntry {\n  conditionDelegate.saveCondition(condition);\n} catch (KettleException e) {\n  log.error(\"Save failed, cause:\", e.getCause());\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"if (!repository.isConnected()) throw new IllegalStateException(\"Connect repository before saving conditions\");","typeGuard":null,"tryCatchPattern":"try { delegate.saveCondition(condition); } catch (KettleException e) { Throwable root = e; while (root.getCause() != null) root = root.getCause(); log.error(\"Save root cause: \", root); throw e; }","preventionTips":["Verify repository writability (disk, permissions) before batch saves","Watch sequence/generator table health","Retry transient DB failures with backoff","Run repository repair/upgrade scripts after version changes"],"tags":["repository","condition","error-wrapper"],"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"}