apache/answer · error

update site info failed: %w

Error message

update site info failed: %w

What it means

addLoginLimitations rewrites the login site_info content JSON (enabling email registrations, clearing domain list) and updates only the 'content' column. If the UPDATE fails, it returns 'update site info failed: %w'.

Source

Thrown at internal/migrations/v10.go:51

func addLoginLimitations(ctx context.Context, x *xorm.Engine) error {
	loginSiteInfo := &entity.SiteInfo{
		Type: constant.SiteTypeLogin,
	}
	exist, err := x.Context(ctx).Get(loginSiteInfo)
	if err != nil {
		return fmt.Errorf("get config failed: %w", err)
	}
	if exist {
		content := &schema.SiteLoginReq{}
		_ = json.Unmarshal([]byte(loginSiteInfo.Content), content)
		content.AllowEmailRegistrations = true
		content.AllowEmailDomains = make([]string, 0)
		data, _ := json.Marshal(content)
		loginSiteInfo.Content = string(data)
		_, err = x.Context(ctx).ID(loginSiteInfo.ID).Cols("content").Update(loginSiteInfo)
		if err != nil {
			return fmt.Errorf("update site info failed: %w", err)
		}
	}

	interfaceSiteInfo := &entity.SiteInfo{
		Type: constant.SiteTypeInterface,
	}
	exist, err = x.Context(ctx).Get(interfaceSiteInfo)
	if err != nil {
		return fmt.Errorf("get config failed: %w", err)
	}
	siteUsers := &schema.SiteUsersReq{
		AllowUpdateDisplayName: true,
		AllowUpdateUsername:    true,
		AllowUpdateAvatar:      true,
		AllowUpdateBio:         true,
		AllowUpdateWebsite:     true,
		AllowUpdateLocation:    true,
	}

View on GitHub (pinned to 3b9f137061)

Solutions

  1. Verify UPDATE privilege on site_info for the migration user
  2. Check the wrapped DB error for lock/timeout/deadlock details
  3. Ensure migrations run during a maintenance window with no concurrent config edits
  4. Re-run the migration after resolving the write failure
Defensive patterns

Strategy: try-catch

Validate before calling

// verify UPDATE rights before the migration attempts writes
if _, err := engine.Exec("SELECT 1 FROM site_info LIMIT 1 FOR UPDATE"); err != nil {
    return fmt.Errorf("site_info not writable/lockable: %w", err)
}

Try / catch

if err := migrations.Migrate(db); err != nil {
    if strings.Contains(err.Error(), "update site info failed") {
        log.Errorf("failed updating login site config (check privileges/locks): %v", err)
    }
    return err
}

Prevention

When it happens

Trigger: x.Context(ctx).ID(loginSiteInfo.ID).Cols("content").Update(loginSiteInfo) errors: write permission denied, row deleted concurrently (ID no longer matches), connection drop, or row locked by another transaction.

Common situations: Migration user lacks UPDATE privilege on site_info; admin deleted/edited the login config while migration runs; DB in read-only maintenance mode.

Related errors


AI-assisted analysis of apache/answer@3b9f137061 (2026-09-05). Data as JSON: /api/errors/83a2a01c03327fe2. Report an issue: GitHub.