`TypeError: err.toJSON is not a function` when webhook URL is invalid
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- github-actions, javascript
Línea de trabajo
Comienza en src/webhook.js, en el bloque catch indicado en la línea 36, y revisa después cómo se llama desde src/send.js y src/index.js. Asegúrate de que una URL de webhook no válida informe del error subyacente sin asumir que la excepción tiene toJSON; se considera terminado cuando se muestra el fallo original en lugar de un TypeError secundario.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
This took a bit for me to track down (my own mistake), thanks to the real error not being shown in the action. If, for example, I accidentally quote the webhook URL, like:
- name: Notify Slack
uses: slackapi/slack-github-action@v2
with:
errors: true
payload: <redacted>
webhook: ${{ toJSON(secrets.SLACK_WEBHOOK_URL) }}
webhook-type: webhook-trigger
I get an exception thrown:
Run slackapi/slack-github-action@v2
Error: TypeError: err.toJSON is not a function
Error: err.toJSON is not a function
TypeError: err.toJSON is not a function
at Webhook.post (file:///home/runner/work/_actions/slackapi/slack-github-action/v2/src/webhook.js:36:1)
at post (file:///home/runner/work/_actions/slackapi/slack-github-action/v2/src/send.js:35:1)
at send (file:///home/runner/work/_actions/slackapi/slack-github-action/v2/src/send.js:15:1)
at file:///home/runner/work/_actions/slackapi/slack-github-action/v2/src/index.js:9:1
file:///home/runner/work/_actions/slackapi/slack-github-action/v2/src/webhook.js:36
const response = err.toJSON();
^
TypeError: err.toJSON is not a function
at Webhook.post (file:///home/runner/work/_actions/slackapi/slack-github-action/v2/src/webhook.js:36:1)
at post (file:///home/runner/work/_actions/slackapi/slack-github-action/v2/src/send.js:35:1)
at send (file:///home/runner/work/_actions/slackapi/slack-github-action/v2/src/send.js:15:1)
at file:///home/runner/work/_actions/slackapi/slack-github-action/v2/src/index.js:9:1
It looks like the catch block is assuming the exception will always have a toJSON function, but in my case it obviously doesn't.
The fix of course, was to remove the erroneous toJSON(...) wrapper from the webhook input, but it would have saved me a lot of time if the exception was handled better by thi action.
Note, the err.toJSON in the exception is unrelated to the toJSON in my input - its only coincidental that we both used (different) toJSON functions (JavaScript vs GitHub Expression respectively).
Cheers.
- Lenguaje dominante
- JavaScript
- Estrellas
- 1.4k
- Forks
- 200
- Merge medio
- 2 h 59 min
- PR fusionados (30 d)
- 6
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de slackapi/slack-github-action
-
docs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
slackapi/slack-github-action#667 ·
-
discussion security semver:major
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
slackapi/slack-github-action#621 · 1 comentario · 1 reacción ·
-
bug: Unexpected token 'o', "ok" is not valid JSONQuizá libre de nuevo @zimeg la tomó hace 51 días y no hay ningún pull request abierto. Abiertodependencies question
slackapi/slack-github-action#671 · 2 comentarios · 1 asignado ·
-
needs info question
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
slackapi/slack-github-action#654 · 7 comentarios · 5 reacciones ·
-
question
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
slackapi/slack-github-action#520 · 1 comentario ·
Todos los issues de slackapi/slack-github-action
Issues similares
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
PedestrianDynamics/pyFDS-Evac#476 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
aiko-chan-ai/DiscordBotClient#380 ·
-
Offisielle trærAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
Daemon delete dialog: "Remove all ExApps" checkbox and `removeExApps` parameter have no effectAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 3 días
-
Add: Atlas TVAbiertochannels:add check:passed
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 4 días