Parse Error when sending slack notifications

Hello, I have a problem when sending notifications using slack orb.

Orb version: 4.12.5

What happened:

When I try to send notifications I get this error:

Posting Status
BASH_ENV file: /tmp/.bash_env-6501b48eb4b50a2a616b6786-0-build
Exists. Sourcing into ENV
Checking For JQ + CURL
Nothing to sanitize.
parse error: Expected another key-value pair at line 9, column 9
parse error: Expected another key-value pair at line 9, column 9

Exited with code exit status 4

Here is my code:

test_notification:
    machine: true
    environment:
      SLACK_ACCESS_TOKEN: token
    steps:
      - slack/notify:
            custom: |
              {
                "blocks": [
                  {
                    "type": "section",
                    "fields": [
                      {
                        "type": "plain_text",
                        "text": "Test notification",
                      }
                    ]
                  }
                ]
              }
            event: always
            channel: channel name

what could be the problem? Thanks!

Try removing the comma at the end of the line

          "text": "Test notification",

I think you have used the example provided as a starting point for your code, but have removed “emoji” field while retaining the comma needed to have the field.

That’s true. A very silly mistake. Thank you!

If I store slack access token as environment variable and remove it from the code it will still work correctly right?

There is only one thing worse than yaml’s white space indenting and that is yaml’s parser’s ability to report errors in a way that allows them to be fixed :slight_smile:

If you mean using Project Settings/Environment Variables as a way to define a variable and value, yes this is injected into the execution environment. As it is passed into the workflow at the start it will be listed in the “Perparing environment variables” step with the assigned value shown as REDACTED to protect it from view.

I have to agree with that the error messages are horrible.

Thank you for your help!