{"record":{"id":"e29d682cadb0c429","repo":"pentaho/pentaho-kettle","slug":"salesforceconnection-exception-query","errorCode":null,"errorMessage":"SalesforceConnection.Exception.Query","messagePattern":"SalesforceConnection\\.Exception\\.Query","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/salesforce/core/src/main/java/org/pentaho/di/trans/steps/salesforce/SalesforceConnection.java","lineNumber":486,"sourceCode":"            this.sObjects = getQueryResult().getRecords();\n            this.queryResultSize = getQueryResult().getSize();\n          }\n          break;\n        default:\n          // return query result\n          this.qr = isQueryAll() ? getBinding().queryAll( getSQL() ) : getBinding().query( getSQL() );\n          this.sObjects = getQueryResult().getRecords();\n          this.queryResultSize = getQueryResult().getSize();\n          break;\n      }\n      if ( this.sObjects != null ) {\n        this.recordsCount = this.sObjects.length;\n      } else {\n        this.recordsCount = 0;\n      }\n    } catch ( Exception e ) {\n      log.logError( Const.getStackTracker( e ) );\n      throw new KettleException( BaseMessages.getString( PKG, \"SalesforceConnection.Exception.Query\" ), e );\n    }\n  }\n\n  public void close() throws KettleException {\n    try {\n      if ( !getQueryResult().isDone() ) {\n        this.qr.setDone( true );\n        this.qr = null;\n      }\n      if ( this.sObjects != null ) {\n        this.sObjects = null;\n      }\n      if ( this.binding != null ) {\n        this.binding = null;\n      }\n      if ( this.loginResult != null ) {\n        this.loginResult = null;\n      }","sourceCodeStart":468,"sourceCodeEnd":504,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/salesforce/core/src/main/java/org/pentaho/di/trans/steps/salesforce/SalesforceConnection.java#L468-L504","documentation":"KettleException wrapping any failure from SalesforceConnection.query(), which executes a SOQL query via the Salesforce SOAP partner binding and loads result records. The original exception is logged with a stack tracker and rethrown with the message key 'SalesforceConnection.Exception.Query'. It means the SOQL query or result retrieval failed at the Salesforce API level.","triggerScenarios":"Calling query() with invalid SOQL, an object/field name that does not exist, expired or invalid Salesforce session binding, or a network failure while fetching QueryResult batches.","commonSituations":"Typo'd field names in the step's SOQL, querying objects with restricted field-level security, session timeout on long-running transformations, Salesforce outage or API deprecation of queried fields.","solutions":["Print the cause (KettleException.getCause()) — SalesforceFault messages name the exact invalid field/object in the SOQL","Validate the SOQL in the Salesforce Developer Console / Workbench before running the transformation","Re-connect (reconnect()/connect) if the session expired, and check username/password/security-token settings","Verify field-level security permissions for the integration user on all queried fields","Check network/proxy connectivity to the Salesforce endpoint"],"exampleFix":"// before\nconnection.query(\"SELECT Id, Nam FROM Account\");\n// after\nconnection.query(\"SELECT Id, Name FROM Account\"); // fix typo; also wrap in try-catch and log getCause()","handlingStrategy":"try-catch","validationCode":"if (soql == null || soql.trim().isEmpty() || !soql.trim().toLowerCase().startsWith(\"select\")) throw new IllegalArgumentException(\"Invalid SOQL: \" + soql);","typeGuard":"boolean isExecutable(Connection c) { try { return c != null && c.getConnection() != null; } catch (Exception e) { return false; } }","tryCatchPattern":"try { connection.query(soql); } catch (KettleException e) { log.logError(\"SOQL failed: \" + e.getCause(), e); /* check session, fix SOQL, retry once */ }","preventionTips":["Test SOQL in Workbench/Developer Console before wiring it into the step","Use getAllAvailableObjects(true) and getFields() to build field lists instead of hand-typing","Call testConnection() before long-running queries and reconnect on session expiry","Keep transformations under the Salesforce session timeout or schedule re-auth","Log getCause() always — the Salesforce fault names the exact bad field/object"],"tags":["salesforce","soql","api","kettle"],"backgroundTag":"api-error-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"}