AlistGo/alist · error
error occurred
Error message
error occurred
What it means
Returned by SSOLoginCallback after a successful HTTP call to the provider's user-info endpoint when the field configured as the user ID is absent from the response — utils.Json.Get returns '' and both '' and '0' are rejected. The generic 'error occurred' message (HTTP 400) masks the real cause: a platform field-mapping mismatch or a failed (but 2xx) token exchange returning an error body.
Source
Thrown at server/handles/ssologin.go:401
common.ErrorResp(c, err, 400)
return
}
if platform == "Dingtalk" {
accessToken := utils.Json.Get(resp.Body(), "accessToken").ToString()
resp, err = ssoClient.R().SetHeader("x-acs-dingtalk-access-token", accessToken).
Get(userUrl)
} else {
accessToken := utils.Json.Get(resp.Body(), "access_token").ToString()
resp, err = ssoClient.R().SetHeader("Authorization", "Bearer "+accessToken).
Get(userUrl)
}
if err != nil {
common.ErrorResp(c, err, 400)
return
}
userID := utils.Json.Get(resp.Body(), idField).ToString()
if utils.SliceContains([]string{"", "0"}, userID) {
common.ErrorResp(c, errors.New("error occurred"), 400)
return
}
if argument == "get_sso_id" {
if usecompatibility {
c.Redirect(302, common.GetApiUrl(c.Request)+"/@manage?sso_id="+userID)
return
}
html := fmt.Sprintf(`<!DOCTYPE html>
<head></head>
<body>
<script>
window.opener.postMessage({"sso_id": "%s"}, "*")
window.close()
</script>
</body>`, userID)
c.Data(200, "text/html; charset=utf-8", []byte(html))
return
}View on GitHub (pinned to 843d9dc814)
Solutions
- Dump/inspect the provider's userinfo response with a real token and set the SSO settings' id field to the key that actually holds a stable non-zero id (e.g. 'id', 'sub', 'uid')
- Verify client id/secret and callback URL — a failed token exchange yields an empty access_token and then this error
- Confirm the selected platform matches the provider (Github/GitLab/OIDC/Dingtalk/Custom) since each pins different token/userinfo endpoints and field names
Example fix
// before: custom platform, user id field = "uid" but provider returns {"id": 42, ...}
// after: set user id field to "id" in SSO settings Defensive patterns
Strategy: try-catch
Validate before calling
userID := utils.Json.Get(resp.Body(), idField).ToString()
if slices.Contains([]string{"", "0"}, userID) {
// dump resp.Body() to logs: field mapping or token exchange is broken
log.Printf("sso userinfo missing %q: %s", idField, resp.Body())
} Try / catch
// Server-side: replace the generic message with actionable context
userID := utils.Json.Get(resp.Body(), idField).ToString()
if slices.Contains([]string{"", "0"}, userID) {
return fmt.Errorf("sso userinfo response has no %q field (status %d): %s", idField, resp.StatusCode(), resp.Body())
} Prevention
- Smoke-test the whole SSO flow (token -> userinfo -> id claim) after any provider or setting change
- Verify client id/secret and callback URL first — failed token exchanges masquerade as this error
- Log the raw userinfo payload when the id field is missing; the generic 'error occurred' hides the cause
When it happens
Trigger: The provider's userinfo JSON does not contain the configured id field (e.g. GitHub 'id' vs OIDC 'sub'); the access_token in the response body is empty because the token endpoint returned an OAuth error object, so the follow-up userinfo fetch returns an error payload without the id.
Common situations: Wrong 'platform' selected for the provider (custom platform with id field name mismatch); wrong client id/secret making the token endpoint return an error body; API rate-limiting or private-user restrictions on GitHub returning partial payloads; OAuth error JSON being silently parsed.
Related errors
- cannot get username from SSO provider
- sso login is disabled
- invalid request
- failed to refresh token: refresh token is empty
- not a jwt token because of invalid segments
AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15).
Data as JSON: /api/errors/6bed01b22e2332af.
Report an issue: GitHub.