Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use underscore delimiter for flattening #281

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rzumer
Copy link

@rzumer rzumer commented Jan 17, 2024

Fixes #280.

Summary

The default key delimiter when flattening payloads is a period, which is not allowed in Slack workflow variable keys. This makes the slack-send action unusable with Slack workflows/incoming webhooks if the payload contains nested keys as there is no way to access those keys (as far as I can tell).

For example if I want to include workflow metadata from GitHub in my payload with ${{ toJson(github) }}, all nested keys are inaccessible, and if I want to compose this with other custom variables by nesting the serialized github values like "github": ${{ toJson(github) }}, "some-key": "some-value", then all of the GitHub metadata is inaccessible because it's all prefixed with github. and can't be entered as a variable key in a Slack workflow. Underscores and hyphens are both valid, so changing to an underscore makes all those nested keys accessible. See flat docs

Tested on a private workflow by building and calling the action directly from my branch.

Requirements (place an x in each [ ])

The default key delimiter when flattening payloads is a period, which is not allowed in Slack workflow variable keys.
Copy link

Thanks for the contribution! Before we can merge this, we need @rzumer to sign the Salesforce Inc. Contributor License Agreement.

@zimeg zimeg added bug Something isn't working semver:major server-side issue labels Apr 12, 2024
@zimeg zimeg added this to the 2.0 milestone Apr 12, 2024
@zimeg
Copy link
Member

zimeg commented Apr 12, 2024

👋 Following up from #280 - I haven't heard of any immediate plans to support dot notation from Workflow Builder so I'm thinking this change is the right way to handle nested payloads going forward.

Since this can change key values of webhook inputs I believe this is a breaking change and will plan to include it in the next major version. Really appreciate the patience on introducing this change so far. We'll take a look at other possible changes we might want to include in a major version before merging this, but please know it's not forgotten!

@rzumer
Copy link
Author

rzumer commented Apr 12, 2024

Thanks for the follow-up!

@zimeg
Copy link
Member

zimeg commented May 15, 2024

👋 Hey @rzumer! Been thinking about this a bit and I'm hoping to avoid making a breaking change here since it's uncertain whether dot notion might eventually be supported by Workflow Builder. Also not wanting to keep this held up since flattening payloads can be super useful, so I was wondering if instead of a replacement, the delimiter can be added as an optional input argument?

I was thinking of something like the following, but let me know what you think and if this sounds good for you!

  - uses: slackapi/slack-github-action@v1.26.0
    with:
      payload: |
        {
          "example": {
            "value": "12"
          }
        }
+     payload-delimiter: '_'
    env:
      SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nested keys in JSON payloads can't be accessed in Slack workflows
2 participants