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

Adding a double quote into a Slack notification string results in a template error #4556

Closed
3 of 4 tasks
jamietanna opened this issue Jan 18, 2024 · 0 comments · Fixed by #4555
Closed
3 of 4 tasks
Assignees
Labels
bug Something isn't working

Comments

@jamietanna
Copy link
Contributor

jamietanna commented Jan 18, 2024

What happened?

When using Slack notifications via blocks or attachments, a template error is seen when using " in the message, for instance when {{ envOrDefault "USER" "" }}

We receive the following error:

slack blocks: failed to evaluate template: template: failed to apply "[{\"text\":{\"text\":\"The current user is {{ envOrDefault \\\"USER\\\" \\\"\\\" }}\",\"type\":\"plain_text\"},\"type\":\"header\"}]": unexpected "\\" in operand

This occurs for both single quoted strings and double quoted strings containing the values:

    blocks:
      - type: header
        text:
          type: plain_text
          text: 'The current user is {{ envOrDefault "USER" "" }}'
    attachments:
        -
          title: Release artifacts
          color: '#2eb886'
            text: |
              The current user is {{ envOrDefault "USER" "" }}

How can we reproduce this?

I've raised a draft PR at #4555 which introduces the test code to reproduce.

goreleaser version

Reproducible on HEAD, commit d15dab3a797e744fac0d0577fc2e3c4ab7a2b758

GoReleaser Check

  • goreleaser check shows no errors

Search

  • I did search for other open and closed issues before opening this

Supporter

Code of Conduct

  • I agree to follow this project's Code of Conduct

Additional context

#4555 is the tests to show the issue

@jamietanna jamietanna added bug Something isn't working triage Issue pending triage by one of the maintainers labels Jan 18, 2024
jamietanna added a commit to jamietanna/goreleaser that referenced this issue Jan 18, 2024
As noted in goreleaser#4556, when we're using a double quote, for use with a
template variable or function, we receive a template parse error as the
value needs to be unquoted.

This provides a slightly hacky solution which is to unquote any quoted
quotes.

Closes goreleaser#4556.
caarlos0 pushed a commit that referenced this issue Jan 19, 2024
…4555)

As noted in #4556, when we're using a double quote, for use with a
template variable or function, we receive a template parse error as the
value needs to be unquoted.

This provides a slightly hacky solution which is to unquote any quoted
quotes.

Closes #4556.
@caarlos0 caarlos0 removed the triage Issue pending triage by one of the maintainers label Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants