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

Don't marshal text property of links when it's empty #38

Merged

Conversation

pipt
Copy link

@pipt pipt commented Jan 10, 2025

Slack returns an error if the text property is empty, but if it's not present everything is fine and it just uses the URL as the text of the link.

Slack returns an error if the text property is empty, but if it's not
present everything is fine and it just uses the URL as the text of the
link.
@@ -364,7 +364,7 @@ func NewRichTextSectionEmojiElement(name string, skinTone int, style *RichTextSe
type RichTextSectionLinkElement struct {
Type RichTextSectionElementType `json:"type"`
URL string `json:"url"`
Text string `json:"text"`
Text string `json:"text,omitempty"`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, I forgot about the omitempty tag
I guess it would have the same effect as changing this to *string , with less effort going around and fixing types

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if we changed the type to *string we'd still need omitempty so we didn't end up with "text": null in the JSON, which Slack also rejects.

@pipt pipt merged commit e88df41 into master Jan 10, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants