Filetype is not available immediately after uploading a file
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 30/100
Línea de trabajo
Empieza con la secuencia de carga y la Slack files.completeUploadExternal response mostradas en el issue, y luego compárala con el chat.postMessage error y el image block payload. No se menciona ningún archivo del repositorio ni ningún test, así que determina primero si este comportamiento corresponde a la action o a la Slack API integration; se considera terminado cuando la causa y una ruta de corrección reproducible estén documentadas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Hi All,
I am trying to send slack message with image from github action, but it is failing everytime. First let me explain, what I am trying to achieve:
- Upload an image in slack
- Extract the permalink of the uploaded image
- Then add that permalink into slack message and send
All these steps are working fine, except it fails to send the message with image. Let me share the code:
Upload image and extract permalink:
` # 📤 Upload Doughnut Chart to Slack & Get Image URL
- name: Upload Chart to Slack
if: always()
run: |
response=$(curl -s -X POST \
-H "Authorization: Bearer ${{ secrets.SLACK_BOT_TOKEN }}" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data "filename=test_results.png&length=$(stat -c%s test_results.png)" \
https://slack.com/api/files.getUploadURLExternal)
echo "Slack Upload URL Response: $response"
upload_url=$(echo "$response" | jq -r '.upload_url')
file_id=$(echo "$response" | jq -r '.file_id')
if [ "$upload_url" == "null" ] || [ "$file_id" == "null" ]; then
echo "⚠️ Failed to get upload URL from Slack."
exit 1
fi
# Step 2: Upload the file to the received URL
upload_response=$(curl -X POST \
-H "Content-Type: image/png" \
-F file=@test_results.png \
"$upload_url")
echo "Slack File Upload Response: $upload_response"
# Step 3: Complete the upload and get the file permalink
complete_response=$(curl -s -X POST \
-H "Authorization: Bearer ${{ secrets.SLACK_BOT_TOKEN }}" \
-H "Content-Type: application/json" \
-d '{
"files": [{"id": "'"$file_id"'", "title": "Test Results"}]
}' \
https://slack.com/api/files.completeUploadExternal)
echo "Slack Complete Upload Response: $complete_response"
image_url=$(echo "$complete_response" | jq -r '.files[0].permalink')
if [ "$image_url" == "null" ]; then
echo "⚠️ Failed to upload image to Slack."
exit 1
else
echo "✅ Image uploaded: $image_url"
echo "IMAGE_URL=$image_url" >> $GITHUB_ENV
fi`
The output it displays:
Send slack message with image:
`# 📢 Send Cypress Results to Slack (With Image & Test Summary)
- name: Send Cypress Results to Slack
if: always()
run: |
curl -X POST \
-H "Authorization: Bearer ${{ secrets.SLACK_BOT_TOKEN }}" \
-H "Content-Type: application/json" \
-d '{
"channel": "XXXXXXX",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "🧪 API Test Report",
"emoji": true
}
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "'"${{ steps.cypress-results.outputs.failed == '0' && '✅ All Tests Passed!' || (steps.cypress-results.outputs.failed != '0' && steps.cypress-results.outputs.passed != '0') && '⚠️ Some Tests Failed' || '❌ All Tests Failed!' }}"'",
"style": {
"bold": true,
"italic": true
}
}
]
}
]
},
{
"type": "divider"
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Total:* `${{ steps.cypress-results.outputs.total }}`\n✅ Pass: `${{ steps.cypress-results.outputs.passed }}`\n❌ Fail: `${{ steps.cypress-results.outputs.failed }}`\n⏭️ Skip: `${{ steps.cypress-results.outputs.skipped }}`"
},
{
"type": "mrkdwn",
"text": "⏱️ Duration: `${{ steps.cypress-results.outputs.duration }} sec`\n📈 Success Rate: `${{ steps.cypress-results.outputs.success_rate }}%`"
}
],
"accessory": {
"type": "image",
"image_url": "${{ env.IMAGE_URL }}",
"alt_text": "Test Results Doughnut Chart"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "📋 *Reports:* • 🔍 <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|GitHub Actions Run> • 📊 <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ env.ARTIFACT_ID }}|Download HTML Report>"
}
]
}
]
}' \
https://slack.com/api/chat.postMessage`
The Output is displaying:
As per the error it is saying that filetype is missing. If you see the output after uploading the image, then you will also see filetype is missing. I do not know if that is the issue. If that is issue, why image filetype is not setting when uploaded by slack api? Any idea or solution?
- 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
-
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
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
jaegertracing/jaeger-ui#4547 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
feedback simulation workshop
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
githubnext/gh-aw-workshop#4090 ·
Los mantenedores suelen responder en 1 día
-
bug deck: add to staging level: missing p-feature: Manage Submissions p-feature: Submissions and process priority: MUST HAVE ready for dev lead role: missing size: missing time sensitive
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
hackforla/tdm-calculator#3581 ·
Los mantenedores suelen responder en 2 días