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

Bug: PublishView always sends empty hash causing hash_conflict errors #1462

@Jaeger-U

Description

@Jaeger-U

Bug Description

The PublishView method incorrectly handles empty hash parameters, causing hash_conflict errors for all home tab updates.

Problem

When calling client.PublishView(userID, view, "") with an empty hash string, the library sends:

{"hash": ""}

According to Slack API docs, to ignore hash validation, the hash field should be omitted entirely from the JSON payload.

Current Behavior

  • All PublishView calls fail with hash_conflict error
  • Home tab views cannot be updated

Expected Behavior

  • Empty hash string should omit the hash field from JSON
  • PublishView should work without hash validation

Code Location

/views.go line ~X (PublishView method)

Workaround

Use PublishViewContext with Hash: nil:

client.PublishViewContext(context.Background(), slack.PublishViewContextRequest{
    UserID: userID,
    View:   view,
    Hash:   nil, // Properly omits hash field
})

Suggested Fix

In PublishView method, check if hash is empty and set to nil:

var hashPtr *string
if hash != "" {
    hashPtr = &hash
}

Environment

  • Library version: v0.17.1
  • Go version: 1.24.6

Metadata

Metadata

Assignees

Labels

bug[issue] bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions