这是indexloc提供的服务,不要输入任何密码
Skip to content

It's Impossible to Omit the EventSubscriptions and Interactivity fields in Manifest's Settings Struct #1460

@pmarkowsky

Description

@pmarkowsky

What happened

Currently the Settings struct in manifest.go defines both EventSubscriptions and Interactivity as struct values rather than pointers, which means omitempty will never take effect.

slack/manifests.go

Lines 189 to 195 in e29b7e3

type Settings struct {
AllowedIPAddressRanges []string `json:"allowed_ip_address_ranges,omitempty" yaml:"allowed_ip_address_ranges,omitempty"`
EventSubscriptions EventSubscriptions `json:"event_subscriptions,omitempty" yaml:"event_subscriptions,omitempty"`
Interactivity Interactivity `json:"interactivity,omitempty" yaml:"interactivity,omitempty"`
OrgDeployEnabled bool `json:"org_deploy_enabled,omitempty" yaml:"org_deploy_enabled,omitempty"`
SocketModeEnabled bool `json:"socket_mode_enabled,omitempty" yaml:"socket_mode_enabled,omitempty"`
}

This results in an empty EventSubscriptions or Interactivity object being passed to Slack as an empty JSON object that is impossible to get rid of and requires you to work around it by doing things like setting an EventSubscriptions object even when you're not using oauth scopes that would require these fields.

Expected behavior

These should be pointers and be omitted when serializing to JSON

Steps to Reproduce

  • Create a Slack app without scopes for EventSubscriptions
  • Create a slack.Manifest{} object without setting EventSubscriptions
  • Call CreateManifestContext(ctx, manifestStruct, your config token)
  • See the error claiming you have an invalid manifest because your EventSubscriptions.RequestUrl is invalid
  • Curse quietly
  • Print the object in logging and see the struct definition
  • Open this issue
  • Open a PR to fix it.

Versions

  • Go: 1.24
  • slack-go/slack: v0.17.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions