Skip to content

Allow empty string to represent apex records - #463

Merged
kntsoriano merged 1 commit into
mainfrom
allow-empty-name
Aug 14, 2025
Merged

Allow empty string to represent apex records#463
kntsoriano merged 1 commit into
mainfrom
allow-empty-name

Conversation

@kntsoriano

@kntsoriano kntsoriano commented Aug 11, 2025

Copy link
Copy Markdown
Contributor

Fixes #451.

Description

When creating a ZoneRecordInput and ZoneRecordUpdateInput with name='', the to_json() command omits the name attribute because of the omitempty command. The omitempty command removes empty strings by default.

This PR changes the behavior to allow a name with an empty string to be rendered by the to_json command. This name with an empty string represents an apex record.

@kntsoriano
kntsoriano requested a review from dallasread August 11, 2025 03:30
@kntsoriano kntsoriano self-assigned this Aug 11, 2025
@kntsoriano kntsoriano added the bug Code defect or incorrect behavior label Aug 11, 2025
@kntsoriano

Copy link
Copy Markdown
Contributor Author

@dallasread Who else do you recommend to review this PR?

@kntsoriano
kntsoriano requested a review from lokst August 11, 2025 03:32
@weppos

weppos commented Aug 11, 2025

Copy link
Copy Markdown
Member

@kntsoriano have you tested that this behavior doesn't conflict with the update? We had this issue in the past, where forcing the empty name to always render, caused issues with updates where we update would reset all names to empty.

This is because on update you can provide a partial changeset (e.g. only TTL), and name should be omitted. But after this change you always pass name which in this case would be empty, causing the update to also reset the name.

Please make sure this change is not introducing bugs on updates.

@kntsoriano

Copy link
Copy Markdown
Contributor Author

@weppos Thanks. I have not considered that and I will look into it tomorrow.

@weppos

weppos commented Aug 11, 2025

Copy link
Copy Markdown
Member

@weppos Thanks. I have not considered that and I will look into it tomorrow.

Please let's make sure we have sufficient test coverage for all these cases. Tests should catch that.

@kntsoriano kntsoriano changed the title Allow empty name for records Allow empty string to represent apex records Aug 13, 2025
@kntsoriano

kntsoriano commented Aug 13, 2025

Copy link
Copy Markdown
Contributor Author

Thanks. I've updated the code to allow passing in an empty string "" to represent the name of an apex record. This is also what we recommend in the API documentation.

We should be safe from the issue where a partial update clears the name as the default value of the name parameter is None and not "". If None is passed, the name attribute is not included in the payload. If "" is passed, the name attribute with the value "" is included in the payload.

I'm requesting another round of review.

@kntsoriano
kntsoriano requested a review from weppos August 13, 2025 03:07
@kntsoriano

Copy link
Copy Markdown
Contributor Author

cc @lokst @dallasread

@lokst lokst left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the fix and adding the test!

@weppos
weppos removed their request for review August 13, 2025 08:47

@dallasread dallasread left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me – thanks for adding the spec.

@kntsoriano
kntsoriano merged commit 81a35ee into main Aug 14, 2025
3 checks passed
@kntsoriano
kntsoriano deleted the allow-empty-name branch August 14, 2025 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Code defect or incorrect behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ZoneRecordInput omits empty name when serialized to json

4 participants