{"record":{"id":"27e1cf37fe7aa1d6","repo":"pentaho/pentaho-kettle","slug":"this-operation-was-cancelled","errorCode":null,"errorMessage":"This operation was cancelled!","messagePattern":"This operation was cancelled!","errorType":"exception","errorClass":"InvocationTargetException","httpStatus":null,"severity":"warning","filePath":"ui/src/main/java/org/pentaho/di/ui/core/database/dialog/GetQueryFieldsProgressDialog.java","lineNumber":65,"sourceCode":"  /**\n   * Creates a new dialog that will handle the wait while we're finding out what tables, views etc we can reach in the\n   * database.\n   */\n  public GetQueryFieldsProgressDialog( Shell shell, DatabaseMeta dbInfo, String sql ) {\n    this.shell = shell;\n    this.dbMeta = dbInfo;\n    this.sql = sql;\n  }\n\n  public RowMetaInterface open() {\n    IRunnableWithProgress op = new IRunnableWithProgress() {\n      public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException {\n        db = new Database( Spoon.loggingObject, dbMeta );\n        try {\n          db.connect();\n          result = db.getQueryFields( sql, false );\n          if ( monitor.isCanceled() ) {\n            throw new InvocationTargetException( new Exception( \"This operation was cancelled!\" ) );\n          }\n        } catch ( Exception e ) {\n          throw new InvocationTargetException( e, \"Problem encountered determining query fields: \" + e.toString() );\n        } finally {\n          db.close();\n        }\n      }\n    };\n\n    try {\n      final ProgressMonitorDialog pmd = new ProgressMonitorDialog( shell );\n\n      // Run something in the background to cancel active database queries, forecably if needed!\n      Runnable run = new Runnable() {\n        public void run() {\n          IProgressMonitor monitor = pmd.getProgressMonitor();\n          while ( pmd.getShell() == null || ( !pmd.getShell().isDisposed() && !monitor.isCanceled() ) ) {\n            try {","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/ui/src/main/java/org/pentaho/di/ui/core/database/dialog/GetQueryFieldsProgressDialog.java#L47-L83","documentation":"GetQueryFieldsProgressDialog executes the user's SQL and derives the result fields via db.getQueryFields(). After the query completes, if the progress monitor reports cancellation, it deliberately throws an InvocationTargetException wrapping 'This operation was cancelled!' so the dialog reports the operation as aborted rather than returning partial field metadata.","triggerScenarios":"Clicking Cancel in the progress dialog while 'get query fields' is running; the monitor.isCanceled() check becomes true after getQueryFields returns (or during it).","commonSituations":"Users cancelling a long-running SQL statement in the SQL editor's field-lookup; slow queries against large tables where the user gives up and cancels.","solutions":["This is expected behaviour when the user cancels: handle the InvocationTargetException and treat the cancellation as a normal outcome, not a failure.","If cancellation appears without a user action, check for a stuck/shared IProgressMonitor that was cancelled by a previous operation.","Avoid re-running heavy getQueryFields calls on huge SQL; limit the SQL statement so it returns quickly."],"exampleFix":"// before\ntry {\n  new GetQueryFieldsProgressDialog( shell, loggingObject, dbMeta, sql ).open();\n} catch ( Exception e ) {\n  e.printStackTrace();\n}\n// after\ntry {\n  new GetQueryFieldsProgressDialog( shell, loggingObject, dbMeta, sql ).open();\n} catch ( InvocationTargetException ite ) {\n  if ( !( ite.getCause() != null && ite.getCause().getMessage().contains( \"cancelled\" ) ) ) {\n    logError( \"Query fields lookup failed\", ite );\n  }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  new GetQueryFieldsProgressDialog( shell, loggingObject, dbMeta, sql ).open();\n} catch ( InvocationTargetException e ) {\n  if ( e.getCause() != null && \"This operation was cancelled!\".equals( e.getCause().getMessage() ) ) {\n    return; // user cancelled; not an error\n  }\n  logError( \"Get fields failed\", e );\n}","preventionTips":["Treat cancellation exceptions as normal control flow, not failures.","Keep monitored SQL short so users rarely need to cancel.","Don't share cancelled IProgressMonitor instances across dialogs."],"tags":["cancellation","progress-dialog","database","sql"],"backgroundTag":"operation-cancelled","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"}