pi-hole / api

The Pi-hole API
Other
162 stars 22 forks source link

gravity_error POSTing to /admin/api/dns/whitelist #128

Closed gh-jamesmontgomery closed 5 years ago

gh-jamesmontgomery commented 5 years ago

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

AzureMarker commented 5 years ago

Thanks for making this issue report!

Is this a fresh install following the steps in this PR? https://github.com/pi-hole/pi-hole/pull/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.

gh-jamesmontgomery commented 5 years ago

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:

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.

gh-jamesmontgomery commented 5 years ago

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