netbirdio/netbird · error

A record is required

Error message

A record is required

What it means

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.

Source

Thrown at management/internals/modules/zones/records/record.go:111

	}

	return nil
}

func (r *Record) EventMeta(zoneID, zoneName string) map[string]any {
	return map[string]any{
		"name":      r.Name,
		"type":      string(r.Type),
		"content":   r.Content,
		"ttl":       r.TTL,
		"zone_id":   zoneID,
		"zone_name": zoneName,
	}
}

func validateIPv4(content string) error {
	if content == "" {
		return errors.New("A record is required") //nolint:staticcheck
	}
	ip := net.ParseIP(content)
	if ip == nil || ip.To4() == nil {
		return errors.New("A record must be a valid IPv4 address") //nolint:staticcheck
	}
	return nil
}

func validateIPv6(content string) error {
	if content == "" {
		return errors.New("AAAA record is required")
	}
	ip := net.ParseIP(content)
	if ip == nil || ip.To4() != nil {
		return errors.New("AAAA record must be a valid IPv6 address")
	}
	return nil
}

View on GitHub (pinned to 93e97f4bf1)

Solutions

  1. Provide the IPv4 address in the content field, e.g. "192.0.2.1".
  2. Make content required client-side for every record type before calling the API.
  3. If you meant to leave the record valueless, that is not supported: skip creating the record instead.

Example fix

// before
{"name": "api", "type": "A", "content": ""}
// after
{"name": "api", "type": "A", "content": "192.0.2.1"}
Defensive patterns

Strategy: validation

Validate before calling

if api.DNSRecordType(req.Type) == api.DNSRecordTypeA && req.Content == "" {
    return fmt.Errorf("content is required for A records")
}

Try / catch

if err := rec.Validate(); err != nil {
    return respondBadRequest(err)
}

Prevention

When it happens

Trigger: A record body {"type":"A","content":""} or with the content key omitted; building a Record with NewRecord(..., "", ...) for an A record.

Common situations: 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.

Related errors


AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16). Data as JSON: /api/errors/2f95430d632598dd. Report an issue: GitHub.