Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

bug: Unexpected token 'o', "ok" is not valid JSON

未关闭
#671 2 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@zimeg 已经在做这个了。

开始于 2026年8月12日。

评估

这个 Issue 还没有评估数据。

描述

dependencies question

Hello and thank you for this action Slack!

Already done a search in both open and closed issues but found none matching my problem. Also looked for open PRs and none fix it either.

When running the GitHub action to notify on failed workflows, as in:

name: Check-Workflow

on:
  workflow_run:
    workflows: ["*"]
    branches: [main]
    types:
      - completed

jobs:
  notify:
    runs-on: ubuntu-latest-small
    if: github.event.workflow_run.conclusion == 'failure'
    permissions:
      contents: read
    steps:
      - name: Slack alert for failure on main
        uses: slackapi/slack-github-action@dcb1066f776dd043e64d0e8ba94ca15cc7e1875d # v4.0.1
        with:
          errors: true
          webhook: ${{ secrets.WEBHOOK_URL }}
          webhook-type: webhook-trigger
          payload: |
            text: "valid text"

It fails with the following error: Error: SlackError: A request error occurred: Unexpected token 'o', "ok" is not valid JSON

Full stacktrace is:

Error: SlackError: A request error occurred: Unexpected token 'o', "ok" is not valid JSON

file:///home/runner/_work/_actions/slackapi/slack-github-action/dcb1066f776dd043e64d0e8ba94ca15cc7e1875d/src/webhook.js:57
      throw new SlackError(config.core, err.message);
^
SlackError: A request error occurred: Unexpected token 'o', "ok" is not valid JSON
    at Webhook.post (file:///home/runner/_work/_actions/slackapi/slack-github-action/dcb1066f776dd043e64d0e8ba94ca15cc7e1875d/src/webhook.js:57:1)
    at processTicksAndRejections (node:internal/process/task_queues:104:5)
    at post (file:///home/runner/_work/_actions/slackapi/slack-github-action/dcb1066f776dd043e64d0e8ba94ca15cc7e1875d/src/send.js:34:1)
    at send (file:///home/runner/_work/_actions/slackapi/slack-github-action/dcb1066f776dd043e64d0e8ba94ca15cc7e1875d/src/send.js:14:1)
    at file:///home/runner/_work/_actions/slackapi/slack-github-action/dcb1066f776dd043e64d0e8ba94ca15cc7e1875d/src/index.js:9:1
Error: A request error occurred: Unexpected token 'o', "ok" is not valid JSON
SlackError: A request error occurred: Unexpected token 'o', "ok" is not valid JSON
    at Webhook.post (file:///home/runner/_work/_actions/slackapi/slack-github-action/dcb1066f776dd043e64d0e8ba94ca15cc7e1875d/src/webhook.js:57:1)
    at processTicksAndRejections (node:internal/process/task_queues:104:5)
    at post (file:///home/runner/_work/_actions/slackapi/slack-github-action/dcb1066f776dd043e64d0e8ba94ca15cc7e1875d/src/send.js:34:1)
    at send (file:///home/runner/_work/_actions/slackapi/slack-github-action/dcb1066f776dd043e64d0e8ba94ca15cc7e1875d/src/send.js:14:1)
    at file:///home/runner/_work/_actions/slackapi/slack-github-action/dcb1066f776dd043e64d0e8ba94ca15cc7e1875d/src/index.js:9:1

Some small research with Claude mentioned the following on why it failed:

1. The Slack action posts to the webhook — Slack actually receives it and responds with ok (plain text).
2. But the action expects JSON back, parses "ok" as JSON → Unexpected token 'o', "ok" is not valid JSON.

Hope this is enough context 🤞

Thank you

主要语言
JavaScript
星标
1.4k
派生
200
平均合并
1 分钟
30 天内合并 PR
8

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

slackapi/slack-github-action 的其他 Issue

查看 slackapi/slack-github-action 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。