this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

prevent HTTP 500 responses for listRepos when one account has no account_repo (#1144)

Accounts sometimes don't have an entry in their account_repo extension
table. This change handles that case for listRepos by including them in
the response but with empty strings for the "Rev" and "Head" fields.

...which probably isn't ultimately correct, but is at least more usable
for clients than missing an entire page of repos because one of them was
affected by this.

placeholder improvement directly related to
https://github.com/bluesky-social/indigo/issues/1143

basically the same as #1142 but that PR only addressed getRepoStatus

---

for what it's worth, the sql join `TODO` suggested in the code here
would have hidden (fixed?) this problem by omitting the affected
accounts, assuming inner-join

authored by

bnewbold and committed by
GitHub
9fa07224 f4a83980

+13 -3
+13 -3
cmd/relay/handlers.go
··· 151 151 // TODO: would be much more efficient to do a join and have Relay.ListAccounts return these repos with the account info 152 152 for i, acc := range accounts { 153 153 repo, err := s.relay.GetAccountRepo(ctx, acc.UID) 154 - if err != nil { 154 + if err != nil && !errors.Is(err, relay.ErrAccountRepoNotFound) { 155 155 s.logger.Error("failed to get repo root", "err", err, "did", acc.DID) 156 156 return nil, echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("failed to get repo root for (%s): %v", acc.DID, err.Error())) 157 157 } 158 + // note: repo can be nil beyond this point! 159 + 160 + // TODO: empty strings here may not be spec-compliant 161 + // need to determine correct handling when there is no account_repo entry 162 + // see https://github.com/bluesky-social/indigo/issues/1143 163 + var cid, rev string 164 + if repo != nil { 165 + cid = repo.CommitCID 166 + rev = repo.Rev 167 + } 158 168 159 169 active := acc.IsActive() 160 170 resp.Repos[i] = &comatproto.SyncListRepos_Repo{ 161 171 Did: acc.DID, 162 - Head: repo.CommitCID, 163 - Rev: repo.Rev, 172 + Head: cid, 173 + Rev: rev, 164 174 Active: &active, 165 175 Status: acc.StatusField(), 166 176 }