Skip to content

Fatal crash on startup: cannot unmarshal number into sso_sync_with_provider (type bool) #250

@fs-bmedkouri

Description

@fs-bmedkouri

Problem

The server authenticates successfully but crashes during user cache warmup with a JSON unmarshal error. The Slack API returns a number for Prefs.team.prefs.sso_sync_with_provider where the Go struct expects a bool.

Error

{"level":"info","message":"Authenticated to Slack"}
{"level":"info","message":"Authenticating with Slack API...","context":"console"}
{"level":"info","message":"Successfully authenticated with Slack","context":"console"}
{"level":"info","message":"Caching users collection...","context":"console"}
{"level":"error","message":"Failed to fetch client user boot","error":"json: cannot unmarshal number into Go struct field Prefs.team.prefs.sso_sync_with_provider of type bool"}
{"level":"error","message":"Failed to fetch users from Slack Connect","error":"json: cannot unmarshal number into Go struct field Prefs.team.prefs.sso_sync_with_provider of type bool"}
{"level":"fatal","message":"Error booting provider","context":"console","error":"json: cannot unmarshal number into Go struct field Prefs.team.prefs.sso_sync_with_provider of type bool"}

Stack trace

github.com/korotovsky/slack-mcp-server/pkg/provider.(*ApiProvider).GetSlackConnect
    /Users/runner/work/slack-mcp-server/slack-mcp-server/pkg/provider/api.go:1010
github.com/korotovsky/slack-mcp-server/pkg/provider.(*ApiProvider).refreshUsersInternal
    /Users/runner/work/slack-mcp-server/slack-mcp-server/pkg/provider/api.go:842
github.com/korotovsky/slack-mcp-server/pkg/provider.(*ApiProvider).RefreshUsers
    /Users/runner/work/slack-mcp-server/slack-mcp-server/pkg/provider/api.go:736
main.main.func1.newUsersWatcher.1
    /Users/runner/work/slack-mcp-server/slack-mcp-server/cmd/slack-mcp-server/main.go:175
main.main.func1
    /Users/runner/work/slack-mcp-server/slack-mcp-server/cmd/slack-mcp-server/main.go:75

Environment

  • Package version: 1.2.3 (latest via npx -y slack-mcp-server)
  • Platform: Windows (amd64), running via MCP client (stdio transport)
  • Auth: Browser cookies (xoxc/xoxd)
  • Workspace type: Standard workspace

Analysis

This is similar to the unmarshal bug fixed in #134 (slack-go/slack v0.17.1 → v0.17.3), but in a different code path. The Prefs struct in pkg/provider/edge/ likely has sso_sync_with_provider typed as bool, but the Slack API returns a numeric value (e.g., 0 or 1) for some workspaces.

Suggested fix

Change the sso_sync_with_provider field type in the Prefs struct to handle both bool and numeric values, or use a custom JSON unmarshaler. Alternatively, use json.Number or interface{} for fields in the prefs struct that may vary in type across workspaces.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions