{"record":{"id":"79a34a934b803a1f","repo":"AdguardTeam/AdGuardHome","slug":"unknown-current-schema-version-d","errorCode":null,"errorMessage":"unknown current schema version %d","messagePattern":"unknown current schema version (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/configmigrate/migrator.go","lineNumber":92,"sourceCode":"\t\treturn body, false, err\n\t}\n\n\tbuf := bytes.NewBuffer(newBody)\n\tenc := yaml.NewEncoder(buf)\n\tenc.SetIndent(2)\n\n\tif err = enc.Encode(diskConf); err != nil {\n\t\treturn body, false, fmt.Errorf(\"generating new config: %w\", err)\n\t}\n\n\treturn buf.Bytes(), true, nil\n}\n\n// validateVersion validates the current and desired schema versions.\nfunc validateVersion(current, target uint) (err error) {\n\tswitch {\n\tcase current > target:\n\t\treturn fmt.Errorf(\"unknown current schema version %d\", current)\n\tcase target > LastSchemaVersion:\n\t\treturn fmt.Errorf(\"unknown target schema version %d\", target)\n\tcase target < current:\n\t\treturn fmt.Errorf(\"target schema version %d lower than current %d\", target, current)\n\tdefault:\n\t\treturn nil\n\t}\n}\n\n// migrateFunc is a function that upgrades a config and returns an error.\ntype migrateFunc = func(ctx context.Context, diskConf yobj) (err error)\n\n// upgradeConfigSchema upgrades the configuration schema in diskConf from\n// current to target version.  current must be less than target, and both must\n// be non-negative and less or equal to [LastSchemaVersion].\nfunc (m *Migrator) upgradeConfigSchema(\n\tctx context.Context,\n\tcurrent, target uint,","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/configmigrate/migrator.go#L74-L110","documentation":"validateVersion rejects the migration because the config's current schema_version is greater than the target version being migrated to. In practice current > target combined with target ≤ LastSchemaVersion means the file claims a version this build doesn't know or a downgrade was attempted.","triggerScenarios":"Calling Migrate on a config whose schema_version exceeds the requested target (e.g. running an older binary against a config written by a newer release, or explicitly passing a low target).","commonSituations":"Rolling back AdGuard Home to an older version while keeping a newer config file, or pinning an older target schema version.","solutions":["If the config came from a newer release, restore the matching (or newer) binary; old builds cannot downgrade configs","Regenerate the config from scratch (the old body is returned on failure, so nothing is lost)","Pass target = LastSchemaVersion supported by your build"],"exampleFix":"// before\nnewBody, ok, err := configmigrate.Migrate(ctx, body, 20) // config is v29\n\n// after\nnewBody, ok, err := configmigrate.Migrate(ctx, body, configmigrate.LastSchemaVersion)","handlingStrategy":"validation","validationCode":"ver, _, _ := fieldVal[int](diskConf, \"schema_version\")\nif uint(ver) > target { /* refuse: downgrade not supported; use newer binary */ }","typeGuard":null,"tryCatchPattern":"if _, _, err := configmigrate.Migrate(ctx, body, target); err != nil && strings.Contains(err.Error(), \"unknown current schema version\") { /* restore matching binary version or fresh config */ }","preventionTips":["Match binary version to config provenance before rolling back","Treat schema_version > supported as 'config from the future', not as corrupt"],"tags":["config","migration","version","schema"],"backgroundTag":"schema-version-mismatch","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}