pi-hole/api

gravity_error POSTing to /admin/api/dns/whitelist

gh-jamesmontgomery opened this issue · 3 comments

I've encountered an issue adding a domain to the whitelist. The entry is added to the list despite the error - it is in the GET response and in the php output of /admin/list.php?l=white .

Reloading the lists manually works without error:

pihole -g --skip-download --whitelist-only
[i] Pi-hole blocking is enabled
[i] Using cached Event Horizon list...
[i] 112317 unique domains trapped in the Event Horizon
[i] Number of whitelisted domains: 3
[i] Number of blacklisted domains: 0
[i] Number of regex filters: 0
[✓] Parsing domains into hosts format
[✓] Cleaning up stray matter
[✓] Force-reloading DNS service
[✓] DNS service is running
[✓] Pi-hole blocking is Enabled

Version:

{
    "api": {
        "branch": "HEAD",
        "hash": "d3aef9a",
        "tag": ""
    },
    "core": {
        "branch": "development",
        "hash": "5950b4b",
        "tag": ""
    },
    "ftl": {
        "branch": "tweak/further_general_improvements",
        "hash": "671ca07",
        "tag": ""
    },
    "web": {
        "branch": "development",
        "hash": "e554991",
        "tag": ""
    }
}

Reponse:

{
    "error": {
        "data": null,
        "key": "gravity_error",
        "message": "Failed to create the blocklist"
    }
}

If I submit the request again - we get an item already exists reponse.

This could be due to how I have the API installed - I noticed that prevous to this I would get access issues to whitelist.txt and blacklist.txt such as:

{
    "error": {
        "data": {
            "file": "/etc/pihole/whitelist.txt"
        },
        "key": "file_write",
        "message": "Error writing to /etc/pihole/whitelist.txt"
    }
}

These were resolved by changing owner and group on the files to 'pihole'.

Any questions about this let me know.

Thanks,

James

Thanks for making this issue report!

Is this a fresh install following the steps in this PR? pi-hole/pi-hole#2692

If so, are you able to reproduce this, and under what environment (distro, architecture, etc)?

Your versions are a bit old, old enough that you might not have installed using the code in the PR I mentioned and therefore have some installation issues. If you didn't install via the steps laid out in the integration PR, try that and see if you still have the issue.

This isn't a fresh installation via that PR. System information:

$ arch
armv7l
$ uname -a
Linux raspberrypi 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l GNU/Linux

The path to this point was:

  • Normal installation

git clone --depth 1 https://github.com/pi-hole/pi-hole.git Pi-hole
cd "Pi-hole/automated install/"
sudo bash basic-install.sh

  • pihole checkout dev (this was two weeks ago)
  • Create API.toml and add

[general]
port = 8000

  • Manually deploy the deb for the API service from https://ftl.pi-hole.net/development/
  • Testing was limited due to shared memory error:

"message": "Incompatible version of shared memory. Found 6, expected 4"

  • My FTL installation was rolled back to get a compatible memory version via pihole checkout ftl tweak/further_general_improvements
  • You made a PR for this.

I've been testing on this older combination. the GET endpoints appear to work fine. I was moving onto configuration modification which is when I got this issue.

I'll try a fresh installation and let you know.

Thanks for taking the time to respond.

I've deployed a fresh server using PR above - POSTing to the whitelist endpoint works without issue. I'll try closing this issue off.