fix(pihole): support special characters in pihole password
What does it do ?
Current implementation does not handle special characters in pihole password correctly. It skips proper JSON marshalling of the request & sends invalid json to pihole API. This change fixes it by introducing proper JSON marshalling.
Motivation
I've hit this problem myself on my homelab setup, here's a log:
time="2025-12-02T13:20:36Z" level=debug msg="Fetching new token from http://http.pi-hole.svc.cluster.local/api/auth"
time="2025-12-02T13:20:36Z" level=debug msg="Error on request http://http.pi-hole.svc.cluster.local/api/auth"
time="2025-12-02T13:20:36Z" level=debug msg="Body of the request {}"
time="2025-12-02T13:20:36Z" level=fatal msg="received 400 status code from request: [bad_request] Invalid request body data (no valid JSON), error at hint (\\hei0MachahmaeThoo7u\"}) - 0.000226s"
Hint in the log is part of the request json starting with invalid escape sequence \h which happened because my password contains backslash.
More
- [x] Yes, this PR title follows Conventional Commits
- [x] Yes, I added unit tests
- [x] Yes, I updated end user documentation accordingly
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: Once this PR has been reviewed and has the lgtm label, please assign raffo for approval. For more information see the Code Review Process.
The full list of commands accepted by this bot can be found here.
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
The committers listed above are authorized under a signed CLA.
- :white_check_mark: login: alex-ac / name: Aleksandr Derbenev (4670796baf5afe4694877d8a5d8ad5f4b6bdfa64, 9481752786637ba8c610c733a799ac8ee75a4c60)
Welcome @alex-ac!
It looks like this is your first PR to kubernetes-sigs/external-dns 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.
You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.
You can also check if kubernetes-sigs/external-dns has its own contribution guidelines.
You may want to refer to our testing guide if you run into trouble with your tests not passing.
If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!
Thank you, and welcome to Kubernetes. :smiley:
Hi @alex-ac. Thanks for your PR.
I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.
Once the patch is verified, the new status will be reflected by the ok-to-test label.
I understand the commands that are listed here.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
/ok-to-test
Pull Request Test Coverage Report for Build 19861145459
Warning: This coverage report may be inaccurate.
This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
- For more information on this, see Tracking coverage changes with pull request builds.
- To avoid this issue with future PRs, see these Recommended CI Configurations.
- For a quick fix, rebase this PR at GitHub. Your next report should be accurate.
Details
- 0 of 0 changed or added relevant lines in 0 files are covered.
- 20 unchanged lines in 2 files lost coverage.
- Overall coverage decreased (-0.008%) to 78.676%
| Files with Coverage Reduction | New Missed Lines | % |
|---|---|---|
| openshift_route.go | 1 | 79.49% |
| pihole/clientV6.go | 19 | 92.26% |
| <!-- | Total: | 20 |
| Totals | |
|---|---|
| Change from base Build 19855624490: | -0.008% |
| Covered Lines: | 16013 |
| Relevant Lines: | 20353 |