Using circleci/slack@4.12 with custom base image

Hi everyone. I have been happily using circleci/slack@4.12 with a convenience python image for quite some time. We are now changing to a custom base image, where we manually install curl and jq, and things seem not to work anymore (see stack below). I am not really sure where to get started for troubleshoot this, any pointers would be greatly appreciated.
Thanks everyone

#!/bin/bash -eo pipefail
#!/usr/bin/env sh

Workaround for Windows Support

For details, see:

shellcheck source=/dev/null

eval printf ‘%s’ “$SLACK_SCRIPT_NOTIFY”

Posting Status
BASH_ENV file: /tmp/.bash_env-6447d8cb93d1e71ebc031dc1-0-build
Exists. Sourcing into ENV
Checking For JQ + CURL

Exited with code exit status 23
CircleCI received exit code 23

For context, if i docker run that image locally, i can successfully curl -d “text=Hi I am a bot that is trying to curl your channel.” -d “channel=” -H “Authorization: Bearer ” -X POST

The error code indicates that there is an error with a command that is being executed within the shell. Without more detail, it is not possible to say what is generating the error or what the error means.

For curl error 23 is “Failed writing body” This can be thrown if the output of curl is being buffered and piped to another program that decides that it can close the pipe while curl is still sending data. Using curl’s -o flag can cause the same error if a file is provided that has to be created in a directory that does not yet exist.

Hi Roger, thanks for replying.
Is there any way i can make the orb more verbose and have a full trace of what goes wrong, or provide more details?

The only reference i have is that this new test step, with curl, works fine:

  - run:
      name: "Test notifications" #
      command: |
        curl -X POST \
          -H "Authorization: Bearer $SLACK_ACCESS_TOKEN" \
          -H 'Content-type: application/json' \
          --data "{\"text\":\"Hello :smile:\", \"channel\":\"$SLACK_DEFAULT_CHANNEL\"}" \

while the old step using the orb, here below, does not

  # - slack/notify:
  #     branch_pattern: master
  #     channel:  CXXXYYYZZZ
  #     event: pass
  #     template: basic_success_1

Really appreciate your help with this

There is no way to make the orb more verbose, but the detail you have provided now allows a good guess at the problem by looking at the orb source code.

Can you check that you have write access to /usr/local/bin, the script seems to want to use curl to download a copy of jq and place it at /usr/local/bin/jq via curl’s -o setting. As this can throw error 23 due to access issues it would be a good place to start.

If you have the time you could validate the issue by taking the code from line 211 of the source code found here

and place it in your test step to see what happens in your environment.

1 Like

That was indeed the problem, once I gave user write access to /usr/local/bin, everything started working again. Thanks a lot for the quick and sharp support, much appreciated :pray:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.