{"record":{"id":"dd5711fcbb3e8041","repo":"netbirdio/netbird","slug":"invalid-cname-target-format","errorCode":null,"errorMessage":"invalid CNAME target format","messagePattern":"invalid CNAME target format","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"management/internals/modules/zones/records/record.go","lineNumber":85,"sourceCode":"\t\treturn errors.New(\"invalid record name format\")\n\t}\n\n\tif r.Type == \"\" {\n\t\treturn errors.New(\"record type is required\")\n\t}\n\n\tswitch r.Type {\n\tcase RecordTypeA:\n\t\tif err := validateIPv4(r.Content); err != nil {\n\t\t\treturn err\n\t\t}\n\tcase RecordTypeAAAA:\n\t\tif err := validateIPv6(r.Content); err != nil {\n\t\t\treturn err\n\t\t}\n\tcase RecordTypeCNAME:\n\t\tif !domain.IsValidDomainNoWildcard(r.Content) {\n\t\t\treturn errors.New(\"invalid CNAME target format\")\n\t\t}\n\tdefault:\n\t\treturn errors.New(\"invalid record type, must be A, AAAA, or CNAME\")\n\t}\n\n\tif r.TTL < 0 {\n\t\treturn errors.New(\"TTL cannot be negative\")\n\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,","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/management/internals/modules/zones/records/record.go#L67-L103","documentation":"For Type == CNAME, Validate() requires Content to pass domain.IsValidDomainNoWildcard. That means an ASCII (or punycode) domain with no \"*.\" prefix, no trailing dot, labels of at most 63 chars starting/ending alphanumeric; the empty string also fails because IsValidDomainNoWildcard returns false for \"\".","triggerScenarios":"A CNAME record whose content is \"*.example.com\", \"target..com\", \"example.com.\", \"café.example.com\" (unicode), \"\", or a label over 63 chars.","commonSituations":"Copying a wildcard alias from another DNS provider that permits wildcard CNAME targets; pasting an FQDN with trailing dot; expecting the record-name wildcard tolerance to also apply to CNAME content (it does not).","solutions":["Use an explicit target domain without the wildcard prefix, e.g. \"target.example.com\".","Remove any trailing dot and punycode-convert unicode targets before submitting.","If you intended a wildcard record name, put the \"*.\" on Name (IsValidDomain allows it), not on the CNAME content."],"exampleFix":"// before\n{\"name\": \"www\", \"type\": \"CNAME\", \"content\": \"*.example.com\"}\n// after\n{\"name\": \"www\", \"type\": \"CNAME\", \"content\": \"example.com\"}","handlingStrategy":"validation","validationCode":"if api.DNSRecordType(req.Type) == api.DNSRecordTypeCNAME && !domain.IsValidDomainNoWildcard(req.Content) {\n    return fmt.Errorf(\"CNAME target %q must be a plain domain without wildcard\", req.Content)\n}","typeGuard":"func isValidCNAMETarget(content string) bool {\n    return domain.IsValidDomainNoWildcard(strings.TrimSuffix(content, \".\"))\n}","tryCatchPattern":"if err := rec.Validate(); err != nil {\n    return respondBadRequest(err)\n}","preventionTips":["Never put \"*.\" on a CNAME target; place wildcards on record names only.","Validate CNAME content with IsValidDomainNoWildcard client-side to mirror the server rule."],"tags":["dns","zones","cname","validation"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}