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

Undefined array key "type" #321

Closed
samdark opened this issue May 23, 2022 · 5 comments
Closed

Undefined array key "type" #321

samdark opened this issue May 23, 2022 · 5 comments
Labels

Comments

@samdark
Copy link

samdark commented May 23, 2022

I'm getting Undefined array key "type" error from time to time at production:

    private function validateMxRecord($dnsRecord) : bool
    {
        if ($dnsRecord['type'] !== 'MX') {
            return true;
        }

Relevant trace:

#86 /vendor/egulias/email-validator/src/Validation/DNSCheckValidation.php(170): Egulias\EmailValidator\Validation\DNSCheckValidation::validateMxRecord
#85 /vendor/egulias/email-validator/src/Validation/DNSCheckValidation.php(150): Egulias\EmailValidator\Validation\DNSCheckValidation::validateDnsRecords
#84 /vendor/egulias/email-validator/src/Validation/DNSCheckValidation.php(110): Egulias\EmailValidator\Validation\DNSCheckValidation::checkDns
#83 /vendor/egulias/email-validator/src/Validation/DNSCheckValidation.php(86): Egulias\EmailValidator\Validation\DNSCheckValidation::isValid
#82 /vendor/egulias/email-validator/src/Validation/MultipleValidationWithAnd.php(66): Egulias\EmailValidator\Validation\MultipleValidationWithAnd::isValid
#81 /vendor/egulias/email-validator/src/EmailValidator.php(37): Egulias\EmailValidator\EmailValidator::isValid

Email validated is [email protected]. It looks like dns_get_record might return info element w/o type specified.

@samdark
Copy link
Author

samdark commented May 25, 2022

Same issue with more emails such as [email protected].

PHP version is 8.1.6 OS is latest Alpine in Docker.

@egulias egulias added the bug label May 27, 2022
@egulias
Copy link
Owner

egulias commented May 27, 2022

Thanks @samdark! dns_get_record is tricky to test. Happy to review and merge a PR ;)

@egulias egulias mentioned this issue May 28, 2022
egulias added a commit that referenced this issue May 28, 2022
* Update dependencies

* dns_get_record wrapper for testing of the function's behaviour

* remove unused classes

* Fix Psalm errors

* Increase PHP Version
@egulias
Copy link
Owner

egulias commented May 30, 2022

Hi @samdark , should be fixed in v3.2 now. Please let me know

@samdark
Copy link
Author

samdark commented May 31, 2022

I'll try upgrading and deploying it to production soon.

@samdark
Copy link
Author

samdark commented Jun 6, 2022

Seems the problem is gone. Thank you.

@samdark samdark closed this as completed Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants