Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow TTL to be empty (to use the default Zone TTL) #4

Open
JPustkuchen opened this issue Aug 19, 2024 · 0 comments
Open

Allow TTL to be empty (to use the default Zone TTL) #4

JPustkuchen opened this issue Aug 19, 2024 · 0 comments

Comments

@JPustkuchen
Copy link

JPustkuchen commented Aug 19, 2024

At Hetzner DNS if TTL is empty, the Zone default TTL is used. This currently isn't supported here,

Currently, when updating a record value with no explicit TTL, the following exception is thrown:

PHP Fatal error: Uncaught MehrIt\HetznerDnsApi\Exceptions\ValidationException: Record ttl must not be empty in /hetzner-api-tools/hetzner-dns-api/src/Concerns/Records.php:154

because of the following validations:

/**
 * Validates the given record
 * @param Record $record The record
 * @throws ValidationException
 */
protected function validateRecord(Record $record): void {

	if (trim($record->getName()) === '')
		throw new ValidationException('Record name must not be empty');
	if (trim($record->getTtl()) === '')
		throw new ValidationException('Record ttl must not be empty');
	if (trim($record->getType()) === '')
		throw new ValidationException('Record type must not be empty');
	if (trim($record->getValue()) === '')
		throw new ValidationException('Record value must not be empty');
	if (trim($record->getZoneId()) === '')
		throw new ValidationException('Record zoneId must not be empty');
}

where

if (trim($record->getTtl()) === '')
    throw new ValidationException('Record ttl must not be empty');

should simply be removed to make it work.

Empty TTL is supported and a nice and helpful feature!

@JPustkuchen JPustkuchen changed the title Allow TTL to be empty (uses the default TTL) Allow TTL to be empty (uses the default Zone TTL) Aug 19, 2024
@JPustkuchen JPustkuchen changed the title Allow TTL to be empty (uses the default Zone TTL) Allow TTL to be empty (to use the default Zone TTL) Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant