You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Slack通知附件侧边色条不生效:配置color为danger仍显示默认灰色

问题原因

你的Payload同时定义了顶级blocks字段和attachments字段,这是导致color: "danger"配置不生效的核心原因。
Slack的消息渲染规则中,当Payload同时存在顶级blocks和attachments时,attachments的颜色属性无法作用到整段消息,仅会显示默认的灰色侧边条。

解决方法

将当前放在顶级的blocks内容移动到attachments内部,删除Payload里的顶级blocks字段即可。修正后的Payload示例如下:

{
    "attachments": [
        {
            "blocks": [
                {
                    "text": {
                        "text": "*Failed*\nDeploy <https://google.com|Test>\nTotal tests: 75 Passed: 75 Total time: 54.1872 Seconds\nError Messages:",
                        "type": "mrkdwn"
                    },
                    "type": "section"
                },
                {
                    "type": "divider"
                },
                {
                    "text": {
                        "text": "This is error 1",
                        "type": "plain_text"
                    },
                    "type": "section"
                },
                {
                    "type": "divider"
                },
                {
                    "text": {
                        "text": "This is error 2",
                        "type": "plain_text"
                    },
                    "type": "section"
                },
                {
                    "type": "divider"
                },
                {
                    "text": {
                        "text": "This is error 3",
                        "type": "plain_text"
                    },
                    "type": "section"
                }
            ],
            "color": "danger"
        }
    ]
}

如果你需要同时保留顶级blocks和attachments结构,颜色条仅会显示在attachments对应的内容区域,不会覆盖整段消息,也就会出现你遇到的整段消息侧边条为灰色的情况。

内容的提问来源于stack exchange,提问作者Shane R

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.25 19:15:04