Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#671 2 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@zimeg ci sta già lavorando.

Dal 12/8/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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

Lingua principale
JavaScript
Stelle
1.3k
Fork
200
Merge medio
2h 59m
PR unite (30g)
6

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di slackapi/slack-github-action

Tutte le issue di slackapi/slack-github-action

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.