{"record":{"id":"7aff79aa432402c8","repo":"AdguardTeam/AdGuardHome","slug":"client-at-index-d-w","errorCode":null,"errorMessage":"client at index %d: %w","messagePattern":"client at index (.+?): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/configmigrate/v6.go","lineNumber":49,"sourceCode":"\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":31,"sourceCodeEnd":60,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/configmigrate/v6.go#L31-L60","documentation":"While migrating clients to schema v6, reading the 'ip' or 'mac' field of a client returned an error from the generic fieldVal helper, typically because the field exists but is not a string (e.g. it is a number, list, or null map type mismatch).","triggerScenarios":"Migrating a config where a client's ip/mac field is quoted incorrectly or stored as a non-string YAML type (e.g. an IP written as a mapping or a list of IPs where a string is expected).","commonSituations":"Hand-crafted client entries with unusual YAML typing; configs migrated from other tools that emit structured values for ip/mac.","solutions":["Check the ip and mac fields of each client in the config; make each a single plain string","Re-run migration after correcting types","If unsure which client is at fault, note the index reported in the message counts from the top of the clients list"],"exampleFix":"# before\nclients:\n  - name: x\n    ip: [192.168.1.5]\n# after\nclients:\n  - name: x\n    ip: 192.168.1.5","handlingStrategy":"validation","validationCode":"// ensure ip/mac are strings before migrating\nfor k, v := range client {\n    if (k == \"ip\" || k == \"mac\") && v != nil {\n        if _, ok := v.(string); !ok { return fmt.Errorf(\"%s must be string\", k) }\n    }\n}","typeGuard":"func isStringField(v any) bool { _, ok := v.(string); return ok }","tryCatchPattern":null,"preventionTips":["Quote scalar values in YAML where ambiguous","Run migration on a copy of config first"],"tags":["config","migration","field-type"],"backgroundTag":"config-schema-migration-failed","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}