Skip to content

Conversation

jortkoopmans
Copy link
Contributor

@jortkoopmans jortkoopmans commented May 19, 2024

This PR proposes a fix for issue #673. The fix involves trimming the zone from the hostname in the request. In addition to the bug fix, this PR includes refactoring for readability and the addition of a testing harness.

  • Trimmed the zone from the hostname in the request to fix issue.
  • Refactored code for improved readability.
  • Added a testing harness which includes:
    • Moving JSON support loading into the sub for testing.
    • Creating a config loader helper sub.

Testing

The actual bugfix is fairly limited, however, I ended up refactoring quite a lot to be able to write some tests. The current architecture of the application made it challenging to test the provider implementation due to:

  • The %config hash being modified globally within the ddclient script (by several subs).
  • The functions (subs) in ddclient not being exported as part of a module, making it difficult to use these functions in tests (outside of the script).

Despite these challenges, I've included some tests in this PR. I understand that this may trigger a discussion about how to improve the structure of the software, which I hope will be to the benefit of this program altogether.

fixes #673

@jortkoopmans jortkoopmans force-pushed the bugfix/673_Fix_DnsExit_subdomain branch from 633df13 to 5b63b88 Compare May 19, 2024 16:01
Copy link
Member

@rhansen rhansen left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

@jortkoopmans jortkoopmans force-pushed the bugfix/673_Fix_DnsExit_subdomain branch 6 times, most recently from b08acdb to ab56cde Compare May 27, 2024 00:48
@jortkoopmans jortkoopmans requested a review from rhansen May 27, 2024 00:58
@rhansen rhansen force-pushed the bugfix/673_Fix_DnsExit_subdomain branch 6 times, most recently from aae2dab to 4fb98cd Compare May 31, 2024 07:28
@jortkoopmans
Copy link
Contributor Author

Amazing work @rhansen 🤩 , it's looking great!
Good solution to revert to empty name by smart trimming, that simplifies the approach. And generally more concise coding 😃 .
I have added a minor improvement, but more importantly I've tested the solution on the DNSExit API and it works fine.

@rhansen rhansen force-pushed the bugfix/673_Fix_DnsExit_subdomain branch from c16af73 to 8dd811f Compare May 31, 2024 23:08
Copy link
Member

@rhansen rhansen left a comment

Choose a reason for hiding this comment

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

@jortkoopmans Thanks for reviewing. I squashed all of the commits together then split into four:

  1. Add tests (marked as expected to fail)
  2. Fix bug (and mark tests as expected to pass)
  3. Don't skip remaining hosts on HTTP error. This commit exists mostly to simplify the next commit: a next can be simply converted into a return whereas last needs additional logic in the calling function.
  4. Move the body of the for loop to a separate function

I split this PR into multiple commits for the following reasons:

  • It makes it easier for downstreams to cherry-pick a minimal diff to fix the issue.
  • It makes it easier for future developers to see what changed.
  • git bisect and git revert will be more useful if this PR breaks something.

Please review the commits one last time (especially the commit messages), make any changes you deem appropriate (force push is OK), and let me know if everything looks OK.

@jortkoopmans
Copy link
Contributor Author

LGTM @rhansen . I have reviewed the commits, commit messages and re-tested the final solution just to be sure; all is good.

jortkoopmans and others added 4 commits June 2, 2024 16:58
Needs LWP::UserAgent.
Trim the zone from the hostname in the request to fix issue.
A non-2xx status code might be host-specific, so ddclient should
continue with the next host.  We could skip the remaining hosts if
there is a connection failure, but it doesn't hurt to retry.
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

Successfully merging this pull request may close these issues.

DNSExit: Updater breaks when provided with a zone and a non-identical hostname (bug)
2 participants