mattermost-community/focalboard · error
SearchBoardsForUserInTeam error getting channelMemberBoardsS
Error message
SearchBoardsForUserInTeam error getting channelMemberBoardsSQL: %w
What it means
channelMemberBoardsQ.ToSql() failed in SearchBoardsForUserInTeam: the channel-membership boards builder could not be rendered. Analogous to error 86 but for the channel-member branch of the UNION.
Source
Thrown at server/services/store/mattermostauthlayer/mattermostauthlayer.go:862
conditions := sq.And{}
for _, word := range strings.Split(strings.TrimSpace(term), " ") {
conditions = append(conditions, sq.Like{"lower(b.title)": "%" + strings.ToLower(word) + "%"})
}
openBoardsQ = openBoardsQ.Where(conditions)
memberBoardsQ = memberBoardsQ.Where(conditions)
channelMemberBoardsQ = channelMemberBoardsQ.Where(conditions)
}
memberBoardsSQL, memberBoardsArgs, err := memberBoardsQ.ToSql()
if err != nil {
return nil, fmt.Errorf("SearchBoardsForUserInTeam error getting memberBoardsSQL: %w", err)
}
channelMemberBoardsSQL, channelMemberBoardsArgs, err := channelMemberBoardsQ.ToSql()
if err != nil {
return nil, fmt.Errorf("SearchBoardsForUserInTeam error getting channelMemberBoardsSQL: %w", err)
}
unionQ := openBoardsQ.
Prefix("(").
Suffix(") UNION ("+memberBoardsSQL, memberBoardsArgs...).
Suffix(") UNION ("+channelMemberBoardsSQL+")", channelMemberBoardsArgs...)
unionSQL, unionArgs, err := unionQ.ToSql()
if err != nil {
return nil, fmt.Errorf("SearchBoardsForUserInTeam error getting unionSQL: %w", err)
}
// if we're using postgres or sqlite, we need to replace the
// question mark placeholder with the numbered dollar one, now
// that the full query is built
if s.dbType == model.PostgresDBType || s.dbType == model.SqliteDBType {
var rErr error
unionSQL, rErr = sq.Dollar.ReplacePlaceholders(unionSQL)View on GitHub (pinned to a84bbb65e3)
Solutions
- Guarantee channelMemberBoardsQ has complete SELECT/FROM before ToSql().
- Inspect the conditions applied just above line 862 for malformed values.
- Verify squirrel version consistency in go.mod/go.sum.
- Unit-test the channel-member search branch.
Defensive patterns
Strategy: try-catch
Try / catch
boards, err := store.GetBoardsForUserAndTeam(userID, teamID, term)
if err != nil {
if strings.Contains(err.Error(), "error getting channelMemberBoardsSQL") {
logger.Error("channel member boards query build failed", "err", err)
return nil, ErrInternalSearch
}
return nil, err
} Prevention
- Ensure channelMemberBoardsQ is complete before ToSql().
- Test with and without channel-membership conditions.
- Watch squirrel version changes after upgrades.
When it happens
Trigger: channelMemberBoardsQ.ToSql() fails after optional Where(conditions) application, during GetBoardsForUserAndTeam search.
Common situations: Invalid builder state from conditional construction; squirrel strictness changes after upgrades; malformed inputs propagating into the builder.
Related errors
- SearchBoardsForUser error getting teamMembersSQL: %w
- SearchBoardsForUser error getting channelMembersSQL: %w
- SearchBoardsForUserInTeam error getting memberBoardsSQL: %w
- SearchBoardsForUser error getting unionSQL: %w
- SearchBoardsForUserInTeam error getting unionSQL: %w
AI-assisted analysis of mattermost-community/focalboard@a84bbb65e3 (2026-08-30).
Data as JSON: /api/errors/b7ea8ad2efc0cd0a.
Report an issue: GitHub.