{"record":{"id":"ee88dd2ab570c58c","repo":"apache/seatunnel","slug":"bulk-job-failed","errorCode":"BULK_JOB_FAILED","errorMessage":"Job \" + jobId + \" ended with state: \" + state","messagePattern":"Job \" \\+ jobId \\+ \" ended with state: \" \\+ state","errorType":"error_code","errorClass":"SalesforceConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-salesforce/src/main/java/org/apache/seatunnel/connectors/seatunnel/salesforce/client/SalesforceClient.java","lineNumber":254,"sourceCode":"\n    private void waitForJobCompletion(String jobId) {\n        String url = authorizedInstanceUrl + String.format(JOB_PATH, params.getApiVersion(), jobId);\n        long deadline = System.currentTimeMillis() + params.getJobCompletionTimeoutMs();\n        while (true) {\n            try {\n                Thread.sleep(params.getPollIntervalMs());\n                HttpGet get = new HttpGet(url);\n                get.setHeader(HttpHeaders.AUTHORIZATION, \"Bearer \" + accessToken);\n                try (CloseableHttpResponse response = httpClient.execute(get)) {\n                    String responseBody =\n                            EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);\n                    String state = objectMapper.readTree(responseBody).get(\"state\").asText();\n                    log.debug(\"Bulk API job {} state: {}\", jobId, state);\n                    if (\"JobComplete\".equals(state)) {\n                        return;\n                    }\n                    if (\"Failed\".equals(state) || \"Aborted\".equals(state)) {\n                        throw new SalesforceConnectorException(\n                                SalesforceConnectorErrorCode.BULK_JOB_FAILED,\n                                \"Job \" + jobId + \" ended with state: \" + state);\n                    }\n                }\n                if (System.currentTimeMillis() > deadline) {\n                    throw new SalesforceConnectorException(\n                            SalesforceConnectorErrorCode.BULK_JOB_FAILED,\n                            \"Job \"\n                                    + jobId\n                                    + \" did not complete within \"\n                                    + params.getJobCompletionTimeoutMs()\n                                    + \"ms\");\n                }\n            } catch (SalesforceConnectorException e) {\n                throw e;\n            } catch (Exception e) {\n                throw new SalesforceConnectorException(\n                        SalesforceConnectorErrorCode.BULK_JOB_FAILED, e);","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-salesforce/src/main/java/org/apache/seatunnel/connectors/seatunnel/salesforce/client/SalesforceClient.java#L236-L272","documentation":"Thrown by SalesforceClient.waitForJobCompletion when the Salesforce Bulk API v2 query job transitions to state 'Failed' or 'Aborted' instead of 'JobComplete'. The message includes the job id and terminal state.","triggerScenarios":"Polling job state and observing 'Failed' (Salesforce rejected/could not execute the query, e.g. query timeout, object locked) or 'Aborted' (job aborted manually or by Salesforce policy).","commonSituations":"SOQL exceeding Salesforce limits (too many records, PBars/query timeout), another process or admin aborting the job, org maintenance causing job failure.","solutions":["Log in to Salesforce (Setup > Bulk Jobs or the job URL) to read the job's failure details/error message","Fix the SOQL: narrow the query with filters, remove unsupported constructs, or reduce the data scope","Re-run the connector to create a fresh job if the job was aborted externally","Check Salesforce org status for maintenance or platform incidents"],"exampleFix":"// before\nsoql = \"SELECT Id, Name, (SELECT Id FROM hugeChild__r) FROM Account\"  // caused Failed\n// after\nsoql = \"SELECT Id, Name FROM Account WHERE CreatedDate > LAST_N_DAYS:30\"","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    client.executeBulkQuery(...);\n} catch (SalesforceConnectorException e) {\n    if (e.getMessage().contains(\"state: Aborted\")) {\n        // job was aborted externally; safe to recreate and retry\n        recreateJobAndRetry();\n    } else {\n        throw e; // genuine query failure, inspect job in Salesforce\n    }\n}","preventionTips":["Avoid overly broad SOQL on huge objects; add WHERE filters","Monitor the job in Setup > Bulk Jobs while the pipeline runs","Coordinate with admins so jobs are not aborted mid-run","Check Salesforce trust status for maintenance windows"],"tags":["salesforce","bulk-api","job-failed"],"backgroundTag":"upstream-api-error","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}