Skip to content

Conversation

@pnx
Copy link

@pnx pnx commented Oct 15, 2025

Description

Make DomainRecordReq.Name be omitted if it's an empty string when encoding to json.
Without this the Name field is wrongly updated to an empty string when calling DomainRecordsServiceHandler.Update()

Checklist:

  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Have you linted your code locally prior to submission?
  • Have you successfully ran tests with your changes locally?

Without this the name field is wrongly updated to an empty string when
calling DomainRecordsServiceHandler.Update()
@github-actions
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Missing Tests

The change affects JSON marshaling behavior for DomainRecordReq.Name. Consider adding tests to verify that empty Name is omitted and non-empty Name is included in JSON output.

Name     string `json:"name,omitempty"`

@github-actions
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Validate empty name handling

Consider whether an empty Name field should be treated as a root record (represented
by "@") rather than omitted entirely, as omitting may cause unexpected behavior when
updating existing records.

domain_records.go [38]

+Name     string `json:"name,omitempty"`
 
-
Suggestion importance[1-10]: 5

__

Why: The suggestion raises a valid concern about empty name handling in DNS records, but this is more of a business logic consideration rather than a code correctness issue. The PR already changed Name from required to optional with omitempty, and this suggestion merely asks to consider the implications without proposing any code change.

Low

Acutally root records are represented by an empty string. So we must use
a pointer here so that it is only omitted if not nil.
Copy link
Member

@optik-aper optik-aper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would work, but I think it would be better to make the update use a different struct, since the create request requires th Name field. Would you mind checking out how that's done elsewhere and copy that behavior? Instance is a good example.

I'm also not convinced we want a string pointer here if we're omitemptying it. An empty string should be sufficient to wipe out the value in the API. Passing nil/null on a string shouldn't be necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants