{"record":{"id":"4e1c2d40d65d9a49","repo":"pentaho/pentaho-kettle","slug":"invalid-shared-object-type-type","errorCode":null,"errorMessage":"Invalid shared object type ${type}","messagePattern":"Invalid shared object type (.+?)","errorType":"exception","errorClass":"KettleXMLException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/shared/XmlFileSharedObjectsIO.java","lineNumber":283,"sourceCode":"      lock();\n      initialize();\n      switch ( SharedObjectType.valueOf( type.toUpperCase() ) ) {\n        case CONNECTION:\n          connectionsNodes.clear();\n          break;\n        case SLAVESERVER:\n          slaveServersNodes.clear();\n          break;\n        case PARTITIONSCHEMA:\n          partitionSchemaNodes.clear();\n          break;\n        case CLUSTERSCHEMA:\n          clusterSchemaNodes.clear();\n          break;\n        default:\n          // unsupported type\n          log.error( \" Invalid Shared Object type \" + type );\n          throw new KettleXMLException( \"Invalid shared object type \" + type );\n      }\n      saveToFile();\n    } finally {\n      unlock();\n    }\n  }\n\n  @Override\n  public void lock() {\n    // Lock the SharedObjectsIO for exclusive access\n    lock.lock();\n  }\n\n  @Override\n  public void unlock() {\n    // Unlock the SharedObjectsIO after exclusive access is no longer needed\n    lock.unlock();\n  }","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/shared/XmlFileSharedObjectsIO.java#L265-L301","documentation":"XmlFileSharedObjectsIO.clear() only supports the known SharedObjectTypes (CONNECTION, SLAVESERVER, PARTITIONSCHEMA, CLUSTERSCHEMA). For any other value it logs an error and throws KettleXMLException 'Invalid shared object type <type>' rather than silently clearing nothing.","triggerScenarios":"Calling clear(type) with a SharedObjectsIO type value outside the four supported enum cases — e.g. a newly added enum constant not yet handled by this implementation, or a null/unknown type.","commonSituations":"Upgrading Pentaho and passing a newer shared object type to an older XmlFileSharedObjectsIO; typos when constructing a type value; code iterating over all types including unsupported ones.","solutions":["Only pass CONNECTION, SLAVESERVER, PARTITIONSCHEMA, or CLUSTERSCHEMA to clear().","Log/inspect the offending 'type' value in the message and fix the caller that produced it.","If a new type is needed, update XmlFileSharedObjectsIO.clear()'s switch to handle it.","Guard the call site by filtering types against the supported set before invoking clear."],"exampleFix":"// before\nxmlFileSharedObjectsIO.clear( someType ); // throws for unknown type\n// after\nif ( EnumSet.of( CONNECTION, SLAVESERVER, PARTITIONSCHEMA, CLUSTERSCHEMA ).contains( someType ) ) {\n  xmlFileSharedObjectsIO.clear( someType );\n}","handlingStrategy":"validation","validationCode":"private static final Set<String> SUPPORTED = Set.of( \"CONNECTION\", \"SLAVESERVER\", \"PARTITIONSCHEMA\", \"CLUSTERSCHEMA\" );\nif ( !SUPPORTED.contains( type ) ) { log.warn( \"Unsupported type: \" + type ); return; }","typeGuard":"boolean isSupportedSharedObjectType( String type ) {\n  return type != null && Set.of( \"CONNECTION\", \"SLAVESERVER\", \"PARTITIONSCHEMA\", \"CLUSTERSCHEMA\" ).contains( type );\n}","tryCatchPattern":"try {\n  io.clear( type );\n} catch ( KettleXMLException e ) {\n  log.error( \"Unsupported shared object type: \" + type, e );\n}","preventionTips":["Only iterate over explicitly supported types","Keep the switch statements in sync when adding enum constants","Unit-test clear/save/load for every SharedObjectsIO type"],"tags":["invalid-enum-value","shared-objects","java"],"backgroundTag":"invalid-enum-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"}