Skip to content

[WPB-27169] Include collaborators in contact search. - #5515

Draft
fisx wants to merge 8 commits into
developfrom
WPB-27169-include-collaborators-in-contact-search
Draft

[WPB-27169] Include collaborators in contact search.#5515
fisx wants to merge 8 commits into
developfrom
WPB-27169-include-collaborators-in-contact-search

Conversation

@fisx

@fisx fisx commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label Sep 3, 2026
fisx and others added 3 commits September 3, 2026 09:11
…rch (second attempt). (#5488)

* Include team collaborators in contact search.

* Implement TeamCollaboratorsSubsystem interpreter with BrigAPIAccess.

Was previously UserSubsystem, but since it TeamCollaboratorsSubsystem
is also used outside of Brig, that is not always available.

Further changes:

- Support BrigAPIAccess locally in Brig.
- Change collaborator field type in UserDoc to collapse `Nothing` and
  `Just []` (remove the Maybe).

* Fix brig-index: do not bump index version in failure case.

* Add release notes on required postgres setup steps.

---------

Co-authored-by: Gautier DI FOLCO <gautier.difolco@wire.com>
@fisx

fisx commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author
        migration to new index from database (force sync):
FAIL
          Exception: IndexMigrationError "ReindexSameOrNewer: failed to sync 1 documents."
          HasCallStack backtrace:
            collectBacktraces, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
            toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/IO.hs:260:11 in ghc-internal:GHC.Internal.IO
            throwIO, called at ./Control/Concurrent/Async.hs:78:13 in tasty-1.5.4-HtsomygUJly7mfNW2QbQBg:Control.Concurrent.Async
          Use -p '(!/turn/&&!/user.auth.cookies.limit/)&&/migration to new index from database (force sync)/' to rerun this test only.

it's flaky, but looks related?

@fisx

fisx commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

also the "failing tests" in bf093e1 are not failing. interesting.

fisx added 4 commits September 7, 2026 10:42
The Problem: User accounts can legitimately be in an inconsistent
state, eg., because a team is in the process of being deleted: Team
member entry is already gone, but brig account entry still exists.
This causes `brig-index`'s bulk sync to fail because Galley returns
404 for team-related lookups.  (The `try`-wrapped calls produce `Left
SomeException`; `mkUserDoc`, `mkDocVersion` handle this by skipping
the account, `ReindexSameOrNewer` throws.)

Evidence from the logs coinciding with a failing index migration:

```
2026-09-02 13:53:42.640 error
{
  "error": "RPCException {"remote" = "galley", "path" = "i/teams/645c4b69-46f1-49a8-be57-35374d0aa947/features/searchVisibilityInbound", "headers" = [("Request-Id","brig-index")],
              "cause" = HttpExceptionRequest
             Request {
              host                 = "galley"
              port                 = 8080
              secure               = False
              requestHeaders       = [("Request-Id","brig-index")]
              path                 = "i/teams/645c4b69-46f1-49a8-be57-35374d0aa947/features/searchVisibilityInbound"
              queryString          = ""
              method               = "GET"
              proxy                = Nothing
              rawBody              = False
              redirectCount        = 10
              responseTimeout      = ResponseTimeoutDefault
              requestVersion       = HTTP/1.1
              proxySecureMode      = ProxySecureWithConnect
            }
             (Response {responseStatus = Status {statusCode = 404,
                    statusMessage = "Not Found"},
                    responseVersion = HTTP/1.1,
                    responseHeaders = [("Transfer-Encoding","chunked"),("Date","Wed, 02 Sep 2026 11:53:35 GMT"),
                                       ("traceparent","00-f96c377d85487f15da6832eed1144233-1f618513676d5162-01"),("tracestate",""),("Content-Encoding","gzip"),("Content-Type","application/json"),("Vary","Accept-Encoding")],
                    responseBody = (),
                    responseCookieJar = CJ {expose = []},
                    responseClose' = ResponseClose,
                    responseOriginalRequest = ...
                    responseEarlyHints = []}) "{\"code\":404,\"label\":\"no-team\",\"message\":\"Team not found\"}")}",

  "userId": "19d790a4-8ac3-4fd9-81a9-ef24af8c8bf9",
  "request": "brig-index",
  "msgs": [
    "E",
    "Error ocurred while indexing user"
  ]
}
```

The solution is graceful degradation: when Galley says "team not
found" (or any Galley error), treat it as "team no longer exists" and
fall back to safe defaults instead of skipping the user entirely.

- **Visibility**: fallback to `SearchableByOwnTeam`.  Rationale:
  `SearchableByOwnTeam` would be an alternative, but in the unlikely
  case that that would be set to "all teams", an account may end up
  being searchable even though the specifically were set up not to.
- **Role**: fallback to `Nothing` (user has no role if the team doesn't exist)
- **Collaborations**: already reads from Postgres, unaffected by Galley 404s

The downstream functions `indexUserToDoc` and `indexUserToVersion` already
accept `Maybe Role` / `Maybe (WithWritetime Role)` and handle `Nothing`
gracefully, so no changes needed there.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants