{"record":{"id":"c71658bbf2e24126","repo":"pentaho/pentaho-kettle","slug":"failed-to-create-repository-for-user-sessionname","errorCode":null,"errorMessage":"Failed to create repository for user: ${sessionName}","messagePattern":"Failed to create repository for user: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"plugins/pur/core/src/main/java/org/pentaho/di/repository/utils/IRepositoryFactory.java","lineNumber":95,"sourceCode":"    @Override\n    public Repository connect( String repositoryName ) throws KettleException {\n\n      IPentahoSession session = PentahoSessionHolder.getSession();\n      if ( session == null ) {\n        logger.debug( \"No active Pentaho Session, attempting to load PDI repository unauthenticated.\" );\n        throw new KettleException( \"Attempting to create PDI Repository with no Active PentahoSession. \"\n            + \"This is not allowed.\" );\n      }\n      ICacheManager cacheManager = PentahoSystem.getCacheManager( session );\n\n      String sessionName = session.getName();\n      try {\n        return (Repository) cacheManager.getOrCreateFromRegionCache( REGION, sessionName, () -> {\n          logger.debug( \"Repository not cached for user: \" + sessionName + \". Creating new Repository.\" );\n          try {\n            return delegate.connect( repositoryName );\n          } catch ( KettleException e ) {\n            throw new IllegalStateException( \"Failed to create repository for user: \" + sessionName, e );\n          }\n        } );\n      } catch ( IllegalStateException e ) {\n        if ( e.getCause() instanceof KettleException kettleException ) {\n          throw kettleException;\n        }\n        throw e;\n      }\n    }\n  }\n\n  /**\n   * Default implementation of the RepositoryFactory. Code moved from PDIImportUtil here pretty much as-is.\n   */\n  class DefaultRepositoryFactory implements IRepositoryFactory {\n    private String repositoryId = \"PentahoEnterpriseRepository\";\n\n    @Override","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/pur/core/src/main/java/org/pentaho/di/repository/utils/IRepositoryFactory.java#L77-L113","documentation":"connect delegates actual repository creation to delegate.connect(repositoryName) inside a cache-loader (getOrCreateFromRegionCache). If the delegate throws a KettleException, it is wrapped in an IllegalStateException carrying 'Failed to create repository for user: <sessionName>'; the outer code unwraps and rethrows the original KettleException when the cause is one. This message indicates repository construction failed for the given user.","triggerScenarios":"Calling connect when delegate.connect fails for any reason — bad repositories.xml, repository unreachable, plugin load failure — while a valid session exists; the user name in the message comes from the active session.","commonSituations":"Wrong repository name; KettleDatabaseRepository missing database driver; network/VPN down to the repository DB; corrupted $HOME/.kettle/repositories.xml.","solutions":["Inspect the chained cause (KettleException) for the real failure and fix it first.","Verify the repository name exists in repositories.xml (repositoriesMeta.findRepository).","Test connectivity to the underlying database/server repository manually.","Clear the per-user repository cache region if a poisoned entry persists after fixing the cause."],"exampleFix":"// before\n} catch (IllegalStateException e) { log.error(e.getMessage()); }\n// after\n} catch (IllegalStateException e) {\n  if (e.getCause() instanceof KettleException ke) {\n    log.error(\"Root cause: \", ke); // inspect real failure\n  }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { repo = factory.connect(name); }\ncatch (KettleException e) { Throwable root = e; while (root.getCause() != null) root = root.getCause(); log.error(\"Repository creation failed\", root); }","preventionTips":["Inspect chained causes, not just the wrapper message","Test delegate.connect() directly to isolate failures"],"tags":["pentaho","repository","session","wrapper-exception"],"backgroundTag":"api-request-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"}