{"record":{"id":"707dc3603d843363","repo":"AdguardTeam/AdGuardHome","slug":"unexpected-type-of-client-at-index-d-t","errorCode":null,"errorMessage":"unexpected type of client at index %d: %T","messagePattern":"unexpected type of client at index (.+?): %T","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/configmigrate/v6.go","lineNumber":42,"sourceCode":"//\t   'mac': 'AA:AA:AA:AA:AA:AA'\n//\t   'ids':\n//\t   - '127.0.0.1'\n//\t   - 'AA:AA:AA:AA:AA:AA'\n//\t  # …\n//\t# …\nfunc (m *Migrator) migrateTo6(_ context.Context, diskConf yobj) (err error) {\n\tdiskConf[\"schema_version\"] = 6\n\n\tclients, ok, err := fieldVal[yarr](diskConf, \"clients\")\n\tif !ok {\n\t\treturn err\n\t}\n\n\tfor i, client := range clients {\n\t\tvar c yobj\n\t\tc, ok = client.(yobj)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type of client at index %d: %T\", i, client)\n\t\t}\n\n\t\tids := yarr{}\n\t\tfor _, id := range []string{\"ip\", \"mac\"} {\n\t\t\tval, _, valErr := fieldVal[string](c, id)\n\t\t\tif valErr != nil {\n\t\t\t\treturn fmt.Errorf(\"client at index %d: %w\", i, valErr)\n\t\t\t} else if val != \"\" {\n\t\t\t\tids = append(ids, val)\n\t\t\t}\n\t\t}\n\n\t\tc[\"ids\"] = ids\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/configmigrate/v6.go#L24-L60","documentation":"During config schema migration to v6, each entry in the clients list failed to assert to the expected map type (map[string]any from YAML/JSON decoding). The schema expects every client to be a mapping object, but at least one is a scalar, list, or of another Go type.","triggerScenarios":"Migrating an old AdGuard Home YAML config where a client entry under 'clients:' is written as a plain string or list instead of a nested mapping of fields.","commonSituations":"Hand-edited YAML config files, configs produced by very old AdGuard Home versions or third-party tools, or a YAML indentation mistake that turns a client block into a scalar.","solutions":["Inspect the clients: section of your YAML config; ensure every item is an indented mapping (e.g. '- name: x\\n  ids: [...]'), not a bare string","Fix or remove malformed client entries and re-run the migration","Restore config.yaml from backup if the file is corrupted"],"exampleFix":"# before\nclients:\n  - 'laptop'\n# after\nclients:\n  - name: laptop\n    ids: [192.168.1.10]","handlingStrategy":"validation","validationCode":"// before migrating, check each client is a mapping\nfor i, c := range rawClients {\n    if _, ok := c.(map[string]any); !ok {\n        return fmt.Errorf(\"client %d is not a mapping\", i)\n    }\n}","typeGuard":"func isClientMap(v any) bool { _, ok := v.(map[string]any); return ok }","tryCatchPattern":null,"preventionTips":["Validate YAML structure with a linter before feeding to migration","Never write client entries as bare strings","Keep backups of config.yaml before upgrades"],"tags":["config","migration","yaml","type-assertion"],"backgroundTag":"config-schema-migration-failed","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}