{"record":{"id":"e1d4b13e7d9a2a55","repo":"apache/seatunnel","slug":"write-to-slack-channel-failed","errorCode":"WRITE_TO_SLACK_CHANNEL_FAILED","errorMessage":"Write to Slack Fail.","messagePattern":"Write to Slack Fail\\.","errorType":"error_code","errorClass":"SlackConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/slack/sink/SlackWriter.java","lineNumber":62,"sourceCode":"        this.conversationId = slackClient.findConversation();\n    }\n\n    @Override\n    public void write(SeaTunnelRow element) throws IOException {\n        Object[] fields = element.getFields();\n        StringJoiner stringJoiner = new StringJoiner(\",\", \"\", \"\\n\");\n        for (Object field : fields) {\n            stringJoiner.add(String.valueOf(field));\n        }\n        String message = stringJoiner.toString();\n        try {\n            slackClient.publishMessage(conversationId, message);\n            // Slack has a limit on the frequency of sending messages\n            // One message can be sent as soon as one second\n            Thread.sleep(POST_MSG_WAITING_TIME);\n        } catch (Exception e) {\n            log.error(\"Write to Slack Fail.\", ExceptionUtils.getMessage(e));\n            throw new SlackConnectorException(\n                    SlackConnectorErrorCode.WRITE_TO_SLACK_CHANNEL_FAILED, e);\n        }\n    }\n\n    @Override\n    public void close() throws IOException {}\n}\n","sourceCodeStart":44,"sourceCodeEnd":70,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/slack/sink/SlackWriter.java#L44-L70","documentation":"SlackWriter.write posts a message to a Slack channel via SlackClient.publishMessage, then sleeps ~1s to respect Slack's send-rate limits. Any exception — publish failure, network error, or interruption during sleep — is logged and rethrown as SlackConnectorException with code WRITE_TO_SLACK_CHANNEL_FAILED. It signals the sink could not deliver a message to the configured conversation.","triggerScenarios":"write(conversationId, message) fails because publishMessage throws (invalid channel ID, invalid/expired token, missing chat:write scope, message rejected, rate limit) or Thread.sleep is interrupted (InterruptedException caught by the broad catch(Exception)).","commonSituations":"Wrong channel ID after channel deletion/archival; bot lacking chat:write scope or not a member of the channel; Slack 429 rate limits on high-throughput sinks; job cancellation interrupting the rate-limit sleep.","solutions":["Check the logged ExceptionUtils.getMessage(e) for the root cause (auth vs channel vs rate limit).","Verify the bot token has chat:write scope and the bot is invited to the target channel.","Confirm the conversation ID is valid and the channel is active.","Reduce sink parallelism/throughput or add buffering if hitting Slack rate limits.","Treat InterruptedException specially if job cancellation is repeatedly triggering this error."],"exampleFix":"// before: broad catch turns cancellation into a write failure\ncatch (Exception e) { throw new SlackConnectorException(..., e); }\n// after\ntry {\n    slackClient.publishMessage(conversationId, message);\n} catch (InterruptedException e) {\n    Thread.currentThread().interrupt();\n    return; // honor cancellation\n} catch (Exception e) {\n    throw new SlackConnectorException(WRITE_TO_SLACK_CHANNEL_FAILED, e);\n}","handlingStrategy":"retry","validationCode":"// pre-check channel membership and scope\ncallSlackApi(\"conversations.info\", Map.of(\"channel\", conversationId)); // validates channel + access","typeGuard":null,"tryCatchPattern":"try {\n    slackWriter.write(conversationId, message);\n} catch (SlackConnectorException e) {\n    if (isRateLimited(e)) {\n        Thread.sleep(backoff); retry();\n    } else {\n        log.error(\"Permanent Slack write failure: {}\", ExceptionUtils.getMessage(e));\n        throw e;\n    }\n}","preventionTips":["Keep sink parallelism low; Slack limits ~1 message/second per channel.","Verify chat:write scope and bot channel membership before jobs run.","Batch or buffer messages instead of sending one per row.","Check ExceptionUtils.getMessage output in logs to classify auth vs rate-limit errors."],"tags":["slack","sink","message-publish"],"backgroundTag":"api-error-response","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}