MCPcopy Index your code
hub / github.com/bytebase/bytebase / workspaceResolutionError

Function workspaceResolutionError

backend/api/oauth2/token.go:231–237  ·  view source on GitHub ↗

workspaceResolutionError maps the typed errors from resolveBoundWorkspace onto RFC 6749 OAuth2 error responses. Membership failure is invalid_grant (400); everything else is an internal failure surfaced as server_error (500) with the wrapped detail logged server-side, not leaked to the client.

(c *echo.Context, err error)

Source from the content-addressed store, hash-verified

229// (400); everything else is an internal failure surfaced as server_error
230// (500) with the wrapped detail logged server-side, not leaked to the client.
231func workspaceResolutionError(c *echo.Context, err error) error {
232 if errors.Is(err, errWorkspaceNotMember) {
233 return oauth2Error(c, http.StatusBadRequest, "invalid_grant", "user is no longer a member of the workspace")
234 }
235 slog.Error("OAuth2 workspace resolution failed", log.BBError(err))
236 return oauth2Error(c, http.StatusInternalServerError, "server_error", "failed to resolve workspace")
237}
238
239// errWorkspaceNotMember signals that the user has been removed from the
240// workspace their OAuth grant was issued for. Mapped to RFC 6749 `invalid_grant`

Callers 2

Calls 3

BBErrorFunction · 0.92
oauth2ErrorFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected