Repository navigation
Non-existing ENV variables are reported with ??? instead of empty value #226
Description
Activity
- addedenhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
on Jul 5, 2023 I wanted to work on this issue, but I am having some trouble reproducing this behavior. Here's what I have in my workflow:
name: CI # Controls when the workflow will run on: # Triggers the workflow on push or pull request events but only for the "main" branch push: branches: ["main"] pull_request: branches: ["main"] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: # This workflow contains a single job called "build" build: # The type of runner that the job will run on runs-on: ubuntu-latest # Steps represent a sequence of tasks that will be executed as part of the job steps: - name: Send custom JSON data to Slack workflow id: slack uses: slackapi/slack-github-action@v1.24.0 with: payload: | { "text": "This is an invalid environment variable: ${{ env.SAMPLE_ENV_VAR }}", "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": "This is an invalid environment variable: ${{ env.SAMPLE_ENV_VAR }}" } } ] } env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
SAMPLE_ENV_VARis the non-existing environment variable but I do not see???in the output:
Am I misunderstanding something?
I wanted to work on this issue, but I am having some trouble reproducing this behavior.
...
Am I misunderstanding something?yes. do it with
payload-file-path.- name: "Slack Notify: Deployment Complete" uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 id: slack-notify env: SLACK_BOT_TOKEN: ${{ inputs.SlackBotToken }} DEPLOYRELEASEBRANCH_APPNAME: ${{ inputs.AppName }} DEPLOYRELEASEBRANCH_APPVERSION: ${{ inputs.AppVersion }} DEPLOYRELEASEBRANCH_ENVIRONMENT: ${{ inputs.Environment }} DEPLOYRELEASEBRANCH_JOBNAME: ${{ inputs.JobName }} DEPLOYRELEASEBRANCH_JOBURL: ${{ inputs.JobUrl }} DEPLOYRELEASEBRANCH_GITHUBACTOR: ${{ inputs.GithubActor }} with: channel-id: ${{ inputs.SlackChannelId }} update-ts: ${{ inputs.MessageId }} payload-file-path: ${{ github.action_path }}/slack-notification.json
Reacted by Eden ZimbelmanSomewhat related, but missing
github.*variables in thepayload-file-pathare also displayed as???. This specific case is being tracked over in #203!👋 I'm finding this can use magic syntax @seratch suggested to default to empty values from the workflow file! With the latest
@v2release, the following step might be useful:- name: Share an update uses: slackapi/[email protected] with: method: chat.postMessage payload-file-path: ./example.json payload-templated: true token: ${{ secrets.SLACK_BOT_TOKEN }} env: COMMIT_HASH: ${{ github.sha || '' }} # This line has the blank default! SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}
With an
example.jsonlike so:{ "channel": "${{ env.SLACK_CHANNEL_ID }}", "text": "A commit landed: ${{ env.COMMIT_HASH }}" }If the
githubevent was to not have the matching values, the empty string would be used!This should also apply to the
@v1tags so I'll close this issue, but wanted to leave a few more notes for updating 📚- The
payload-templatedvariable can be used for both types of payloads! - The
payload-templatedvariable replaces thepayload-file-path-parsedoption! - The
payload-templatedvariable must be true to replace templated variables!
Finding certain values in the GitHub context can also be a cause of confusion, and options available when replacing templatized variables are available from the default GitHub event.
I'll close this issue with the workaround, but please feel free to comment with other ideas or follow up questions about this. I'm super open to ideas for enhancement here 🙏
- The
Description
If a env variable which is in payload is missing, ??? are sent instead of empty value.
It would be nice to not put ??? which confuses people but leave it empty (like empty variable).
What type of issue is this? (place an
xin one of the[ ])Requirements (place an
xin each of the[ ])Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Reproducible in:
package version: latest
Steps to reproduce:
Expected result:
Instead of ??? I would expect missing variable to be shown just empty value (bash behavior)
Actual result:
Instead of empty, we get confusing ???
Attachments:
For example: