TechnitiumSoftware/DnsServer · error · ArgumentOutOfRangeException
Resource record comment text cannot exceed 255 characters.
Error message
Resource record comment text cannot exceed 255 characters.
What it means
Thrown by GenericRecordInfo.Comments setter when the supplied string is non-null and longer than 255 characters. The 255 limit is mandated by the binary persistence format: comments are stored via WriteShortString (a length-prefixed byte field), so anything longer would overflow the field and corrupt the record on disk. The check runs on every assignment to keep the invariant at the boundary.
Source
Thrown at DnsServerCore/Dns/ResourceRecords/GenericRecordInfo.cs:135
}
#endregion
#region properties
public virtual bool Disabled
{
get { return _disabled; }
set { _disabled = value; }
}
public string Comments
{
get { return _comments; }
set
{
if ((value is not null) && (value.Length > 255))
throw new ArgumentOutOfRangeException(nameof(Comments), "Resource record comment text cannot exceed 255 characters.");
_comments = value;
}
}
public DateTime LastModified
{
get { return _lastModified; }
set { _lastModified = value; }
}
public virtual uint ExpiryTtl
{
get { return _expiryTtl; }
set { _expiryTtl = value; }
}
public DateTime LastUsedOnView on GitHub (pinned to d0484b6c1e)
Solutions
- Truncate the comment to 255 characters before assigning (consider storing longer text elsewhere).
- Validate comment length in your UI/API layer and reject or truncate with a user-facing message.
- If you need longer annotations, store them out-of-band (e.g. a separate notes store) rather than in the record comment.
Example fix
// before
record.Comments = longDescription; // 600 chars
// after
const int MAX_COMMENT = 255;
record.Comments = longDescription is null || longDescription.Length <= MAX_COMMENT
? longDescription
: longDescription.Substring(0, MAX_COMMENT); Defensive patterns
Strategy: validation
Validate before calling
const int MAX_RECORD_COMMENT = 255;
string safe = string.IsNullOrEmpty(comment) || comment.Length <= MAX_RECORD_COMMENT
? comment
: comment.Substring(0, MAX_RECORD_COMMENT);
record.Comments = safe; Type guard
static bool IsValidComment(string s) => s is null || s.Length <= 255;
Try / catch
try { record.Comments = comment; }
catch (ArgumentOutOfRangeException ex) when (ex.ParamName == nameof(record.Comments))
{ record.Comments = comment.Substring(0, 255); } Prevention
- Enforce a 255-char limit in the record editor UI and API input validation.
- Truncate long descriptions before assigning to Comments; store longer text elsewhere.
When it happens
Trigger: Assigning record.Comments to a string whose .Length > 255. Reachable from the web console record editor, the HTTP API, or any App/plugin that sets record metadata.
Common situations: Pasting a long note into a record's comment field; an automated provisioning script copying an unbounded description into Comments; bulk-import with a description column longer than 255 chars.
Related errors
- Display name length cannot exceed 255 characters.
- Cluster node URL length must be less than 255 bytes.
- Zone Signing Key (ZSK) automatic rollover days valid range i
- GenericRecordInfo format version not supported.
- MaxStatFileDays must be greater than or equal to 0.
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/5f1b7123cf2f793f.
Report an issue: GitHub.