{"record":{"id":"2f95430d632598dd","repo":"netbirdio/netbird","slug":"a-record-is-required","errorCode":null,"errorMessage":"A record is required","messagePattern":"A record is required","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"management/internals/modules/zones/records/record.go","lineNumber":111,"sourceCode":"\t}\n\n\treturn nil\n}\n\nfunc (r *Record) EventMeta(zoneID, zoneName string) map[string]any {\n\treturn map[string]any{\n\t\t\"name\":      r.Name,\n\t\t\"type\":      string(r.Type),\n\t\t\"content\":   r.Content,\n\t\t\"ttl\":       r.TTL,\n\t\t\"zone_id\":   zoneID,\n\t\t\"zone_name\": zoneName,\n\t}\n}\n\nfunc validateIPv4(content string) error {\n\tif content == \"\" {\n\t\treturn errors.New(\"A record is required\") //nolint:staticcheck\n\t}\n\tip := net.ParseIP(content)\n\tif ip == nil || ip.To4() == nil {\n\t\treturn errors.New(\"A record must be a valid IPv4 address\") //nolint:staticcheck\n\t}\n\treturn nil\n}\n\nfunc validateIPv6(content string) error {\n\tif content == \"\" {\n\t\treturn errors.New(\"AAAA record is required\")\n\t}\n\tip := net.ParseIP(content)\n\tif ip == nil || ip.To4() != nil {\n\t\treturn errors.New(\"AAAA record must be a valid IPv6 address\")\n\t}\n\treturn nil\n}","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/management/internals/modules/zones/records/record.go#L93-L129","documentation":"validateIPv4 returns this when Type is \"A\" and Content is the empty string. The wording is legacy (the //nolint:staticcheck on the line acknowledges the error-string style); it means the A record's content/value is missing. It fires before the IP parse attempt.","triggerScenarios":"A record body {\"type\":\"A\",\"content\":\"\"} or with the content key omitted; building a Record with NewRecord(..., \"\", ...) for an A record.","commonSituations":"A form that validates name and type but lets the address field submit blank; API consumers that conditionally omit fields instead of sending them; test fixtures that only set type.","solutions":["Provide the IPv4 address in the content field, e.g. \"192.0.2.1\".","Make content required client-side for every record type before calling the API.","If you meant to leave the record valueless, that is not supported: skip creating the record instead."],"exampleFix":"// before\n{\"name\": \"api\", \"type\": \"A\", \"content\": \"\"}\n// after\n{\"name\": \"api\", \"type\": \"A\", \"content\": \"192.0.2.1\"}","handlingStrategy":"validation","validationCode":"if api.DNSRecordType(req.Type) == api.DNSRecordTypeA && req.Content == \"\" {\n    return fmt.Errorf(\"content is required for A records\")\n}","typeGuard":null,"tryCatchPattern":"if err := rec.Validate(); err != nil {\n    return respondBadRequest(err)\n}","preventionTips":["Require content for every record type in the client, not just some.","Treat empty content as a form error before submit."],"tags":["dns","zones","validation","ipv4"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}