apache/answer · error
update site info failed: %w
Error message
update site info failed: %w
What it means
Returned by addGravatarBaseURL when the xorm Update() writing the modified JSON content (with GravatarBaseURL set) back to the users SiteInfo row fails. The read succeeded and the content was unmarshalled/re-marshalled; only the persisted write failed. The driver error is wrapped with %w.
Source
Thrown at internal/migrations/v13.go:74
func addGravatarBaseURL(ctx context.Context, x *xorm.Engine) error {
usersSiteInfo := &entity.SiteInfo{
Type: constant.SiteTypeUsers,
}
exist, err := x.Context(ctx).Get(usersSiteInfo)
if err != nil {
return fmt.Errorf("get config failed: %w", err)
}
if exist {
content := &schema.SiteUsersReq{}
_ = json.Unmarshal([]byte(usersSiteInfo.Content), content)
content.GravatarBaseURL = "https://www.gravatar.com/avatar/"
data, _ := json.Marshal(content)
usersSiteInfo.Content = string(data)
_, err = x.Context(ctx).ID(usersSiteInfo.ID).Cols("content").Update(usersSiteInfo)
if err != nil {
return fmt.Errorf("update site info failed: %w", err)
}
}
return nil
}
func addPrivilegeForInviteSomeoneToAnswer(ctx context.Context, x *xorm.Engine) error {
// add rank for invite to answer
powers := []*entity.Power{
{ID: 38, Name: "invite someone to answer", PowerType: permission.AnswerInviteSomeoneToAnswer, Description: "invite someone to answer"},
}
for _, power := range powers {
exist, err := x.Context(ctx).Get(&entity.Power{PowerType: power.PowerType})
if err != nil {
return err
}
if exist {
_, err = x.Context(ctx).ID(power.ID).Update(power)
} else {View on GitHub (pinned to 3b9f137061)
Solutions
- Read the wrapped driver error to identify the SQL failure
- Verify UPDATE privilege on site_info and adequate column size for content
- Re-run the migration; it only writes when the users site info row exists
Example fix
// before
_, err = x.Context(ctx).ID(usersSiteInfo.ID).Cols("content").Update(usersSiteInfo)
if err != nil {
return fmt.Errorf("update site info failed: %w", err)
}
// after (log which row failed)
_, err = x.Context(ctx).ID(usersSiteInfo.ID).Cols("content").Update(usersSiteInfo)
if err != nil {
return fmt.Errorf("update site info id=%d failed: %w", usersSiteInfo.ID, err)
} Defensive patterns
Strategy: try-catch
Validate before calling
// ensure content column can hold the updated JSON
var size int
db.QueryRow("SELECT CHARACTER_MAXIMUM_LENGTH FROM information_schema.columns WHERE table_name='site_info' AND column_name='content'").Scan(&size)
// ensure size is large enough (e.g. TEXT not VARCHAR(255)) Try / catch
if err := runMigrations(); err != nil {
if strings.Contains(err.Error(), "update site info failed") {
log.Fatalf("site_info write failed, cause: %v", errors.Unwrap(err))
}
} Prevention
- Use a sufficiently large column type for site_info.content
- Avoid concurrent admin edits to site info during upgrades
- Grant the migration user UPDATE privileges
- Re-run the migration; the write only happens when the row exists
When it happens
Trigger: x.Context(ctx).ID(usersSiteInfo.ID).Cols("content").Update(usersSiteInfo) returns non-nil err in the v13 migration.
Common situations: Content column size limit exceeded by the larger JSON; row locked by concurrent admin edit; write privileges removed; connection dropped between read and write.
Related errors
- get config failed: %w
- %s failed: %s
- sync version failed: %v
- get config failed: %w
- update config failed: %w
AI-assisted analysis of apache/answer@3b9f137061 (2026-09-05).
Data as JSON: /api/errors/abaf0fbaa99638c0.
Report an issue: GitHub.