{"record":{"id":"8a5248d666407b58","repo":"pentaho/pentaho-kettle","slug":"failed-with-error-code","errorCode":null,"errorMessage":"Failed with error-code ","messagePattern":"Failed with error-code ","errorType":"exception","errorClass":"RepositoryClientException","httpStatus":null,"severity":"error","filePath":"plugins/repo-vfs/repo-vfs-ws/src/main/java/org/pentaho/di/plugins/repovfs/ws/repo/RepositoryClient.java","lineNumber":204,"sourceCode":"  }\n\n  protected boolean isKettleFile( String fileName ) {\n    switch ( FilenameUtils.getExtension( fileName ).toLowerCase() ) {\n      case Const.STRING_TRANS_DEFAULT_EXT:\n      case Const.STRING_JOB_DEFAULT_EXT:\n        return true;\n      default:\n        return false;\n    }\n  }\n\n  /** Delete file or folder */\n  public void delete( RepositoryFileDto file ) throws RepositoryClientException {\n    final WebTarget target = client.target( url + cfg.getDeleteFileOrFolderUrl() );\n    Response response = target.request( MediaType.TEXT_PLAIN ).put( Entity.entity( file.getId(), MediaType.TEXT_PLAIN ) );\n\n    if ( response == null || response.getStatus() != Response.Status.OK.getStatusCode() ) {\n      throw new RepositoryClientException( \"Failed with error-code \" + response.getStatus() );\n    }\n  }\n\n  /** Upload file with given data to the server */\n  public void writeData( final String[] fileName, InputStream data ) throws RepositoryClientException {\n    final StringBuilder pathBuilder = new StringBuilder();\n    for ( int i = 0; i < fileName.length; i++ ) {\n      if ( i != 0 ) {\n        pathBuilder.append( \"/\" );\n      }\n      pathBuilder.append( fileName[ i ] );\n    }\n    String path = encodePath( pathBuilder.toString() );\n    String service = cfg.getUploadSvc( path );\n\n    final WebTarget target = client.target( url + service );\n    Response response = target.request( MediaType.TEXT_PLAIN ).put( Entity.entity( data, MediaType.TEXT_PLAIN ) );\n","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/repo-vfs/repo-vfs-ws/src/main/java/org/pentaho/di/plugins/repovfs/ws/repo/RepositoryClient.java#L186-L222","documentation":"delete() PUTs the file/folder ID to the delete endpoint and throws RepositoryClientException(\"Failed with error-code \" + status) whenever the response is null or its HTTP status is not 200 OK. The status code is appended so the caller can see what the server returned.","triggerScenarios":"Calling delete() when the server returns a non-200 status (401 unauthorized, 403 forbidden, 404 file not found, 500 server error), or when no response object comes back.","commonSituations":"Deleting a file that another session already removed; user lacking delete permissions; session/cookie expired mid-operation; server-side lock or referencing content preventing deletion.","solutions":["Read the appended status code: 401/403 -> re-authenticate or check permissions; 404 -> treat as already deleted; 5xx -> check server logs","Call getFileInfo() first to confirm the file still exists before deleting","Refresh authentication/cookies and retry the delete","Check server-side references/locks on the file that may block deletion"],"exampleFix":"// before\nclient.delete( file ); // may throw on 404\n// after\nif ( client.getFileInfo( path ).isPresent() ) {\n  try {\n    client.delete( file );\n  } catch ( RepositoryClientException e ) {\n    log.warn( \"Delete failed: {}\", e.getMessage() ); // contains error-code\n  }\n}","handlingStrategy":"try-catch","validationCode":"// Confirm the file exists before deleting\nboolean exists = client.getFileInfo( path ).isPresent();\nif ( exists ) { client.delete( file ); }","typeGuard":"boolean deletable( RepositoryClient c, RepositoryFileDto f ) {\n  return f != null && f.getId() != null && c.getFileInfo( path ).isPresent();\n}","tryCatchPattern":"try {\n  client.delete( file );\n} catch ( RepositoryClientException e ) {\n  if ( String.valueOf( e.getMessage() ).contains( \"404\" ) ) {\n    log.info( \"Already deleted\" ); // idempotent handling\n  } else if ( String.valueOf( e.getMessage() ).contains( \"401\" ) ) {\n    reauthenticate();\n  }\n}","preventionTips":["Treat delete as potentially idempotent - 404 means already gone","Re-authenticate on 401/403 status codes in the message","Check permissions on the target before deletion","Fetch fresh file metadata (IDs change) right before deleting"],"tags":["http","rest","delete","status-code"],"backgroundTag":"http-non-200-response","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"}