-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Error "400: Bad Request" on all queries #281
Comments
I'm seeing this as well...thought it was something with my install or an update or something. Let me know what other data I can provide from my install to help here. |
My queries all failed too. When I removed the Line Feeds and made it a single line statement the queries and updates worked again. |
+1 Reverted to v3.9.2 from backup which is still working without any issues. |
@BigThunderSR Good to know, might help some people. Unfortunately I don't have any old versions in my backups I could restore, as 3.10.0 was my first install of the addon. |
Same problem |
@maia, see if this works for you to install (restore to) v3.9.2. You'll need to unzip it to get the "addon_a0d7b954_sqlite-web_3.9.2.tar" file which is what you need to use to restore this version in HA because GitHub doesn't let you upload .tar files. |
@BigThunderSR Much appreciated. I'm quite new to HA yet, so I'll have to figure out where to place the tar file and how to let HA know to use it to install the addon. I assume there's a path it accepts as local repository. |
@BigThunderSR Thank you for your service. Your Backup worked for me. @maia restoring from Backup is pretty easy. First delete the installed Addon then go to Settings > System > Backup and choose Upload Backup in the top right menu and upload the tar. |
It also worked for me. But don't forget to disable the "Auto update" as today I suddenly had 3.10.0 again... |
When I try that I get 404: Not Found error |
I am also receiving this error for 99% of queries. Running v3.10.0 of the add-on. Unfortunately no back to restore a previous version from. Is there any eta on a fix? |
You can use the backup file I provided here until a fix is available: #281 (comment) |
It seems that the queries have to be all on one line, then they work |
Thank you very much! Works perfectly. Turned auto update off for the time being. |
One line statement doesn't work for me - I get a Bad Request too. Perhaps my statement is too long, because it automatically wraps line. |
There seem to be two things. If I make a query like:
This works if (a) it's on one line. (b) I actually click on the statistics database and then query, as opposed to typing it into the main query box. If I don't do (b), I get the 404 error. If I do (b) but not (a), I get a 400 error. I've managed to get some pretty long queries done in this way, but they are completely unreadable. In any case, this is at best a bad workaround and clearly there is some sort of bug. |
@wigster I could also fix my queries by writing them in one line. Using the Query box at the home screen also gives me the error 404. |
I discovered that multi-line statements create the
Using one-line statements instead works again. What an ugly bug... no matter when or why this has been introduced. Either HA Core (starting 2023.4 likely) or one of the latest addon updates. Home screen query box not working at all, no matter if multi- or one-line statements are used. I tend to say the addon is partly broken. |
@bcutter |
Strongly disagree. That's a workaround (like using one-liner statements), at best. A solution would be the addon to provide a new version which downgrades it to a working state version. |
I think it was offered as a workaround to someone, not a final solution. I assume the author will at some point tackle this and fix it more completely. They may be off on a long ocean cruise or something. :) |
Indeed it's currently the only working solution till the author is coming with a fix on 3.10.0 So let the author enjoy that "long ocean cruise" and who knows it gets resolves somewhere in the future. |
Note the recent |
That's a shame. It does appear that with current HA versions the old working one still works (I am a bit confused by the whole /config -> /homeassistant migration whether it would break anything, but the link from config still seems to work with older tools). |
agree. I can understand the effort the developers put on , but a known bug exists for more than a month , new release is published and the bug still exists. |
Just from looking at the PR history the "owner" of this is someone who seems to own about half the addons out there, and the most recent changes were largely compatibility changes for ongoing HA work done by someone else. I.e. I think this addon is a tail wagged by a larger dog for the latest changes, not someone actually working on this add-on specifically. I don't know any of the folks involved nor am I involved in HA generally, just remember these are all volunteers who keep this particular train running, so when it runs on time, be impressed, and a little forgiving if it's late. |
I fully agree with you. I did a rollback to 3.9.2 and all is working fine for me. So even if it takes a year to fix the issue, I'm not blocked. But I have to say that I was surprised to see that after 3.10.0 also 4.0.0 is having the issue. I assume that the person who released the latest version did some basic testing before releasing it, and for that person it then worked. So is there maybe something "else" causing the issue? A conflict with our configuration maybe? |
I created an issue over at coleifer/sqlite-web#140, fingers crossed something can be done. |
it seems that not everyone has GET? |
it’s still GET. What they reported is the URL the browser shows, mine is the same. It’s just running in a frame, so you can’t see the query in the URL. But if you right-click view frame source you can see the URL with the GET query. |
you're right, I always opened in a new window, not in a frame and that's why I pointed it out |
Just jumping in here from coleifer/sqlite-web#140 -- here's the comment I posted: I think this is a bug in the "ha" code, as it's perfectly fine for newlines and carriage returns to be passed in the GET as long as they're quoted (as far as I can tell): >>> from urllib.parse import *
>>> unquote('q=foo%0D%0Abar')
'q=foo\r\nbar'
>>> parse_qs('q=foo%0D%0Abar')
{'q': ['foo\r\nbar']} As you can see, Python has no problems with newlines. It's the janky middleware in the "ha" application that is being overly-strict, in my opinion. Nonetheless, and because in the name of that holiest talisman "security" any nonsense is justifiable nowadays, I doubt the HA people will walk this back any time soon. So I've patched it on my side to return the form to a POST by default (though GET is still supported). |
This fixes hassio-addons#281
Thanks @coleifer, I really appreciate the quick turnaround even despite not fully agreeing with the underlying reasons. |
If you're willing to "Live on the edge" (pun intended), you can install the Edge version of SQLite Web Addon at: https://addons.community/edge/ It includes the fixed version that was merged in #294. Otherwise, you can wait until the next release whenever that happens. I just installed the Edge version, which fixes the problem of new lines in SQL queries. I'm unsure if the edge version auto-update's though, so it might just a workaround until the next release. |
I added the edge repository but I'm unclear how to install the add-on from the edge repo. After adding the repo, I uninstalled SQLIteWeb but when trying to install, it still shows v4.1.0. From the HA EDGE page, there's no instructions :( Would you mind sharing how you've done it? Thank you. |
I think it takes quite a while for the edge repository to install. I reckon it might have been like 5 minutes until I could install things from it. I was impatient enough that I removed the repository and added it a few times until I went and did something else then I noticed I was getting 2 results in the add-on store for SQLite web. The edge version is bb44e95 for me instead of 4.1.0. I hope that helps. |
Came back here ~5 hours later and read your reply. I was impatient as well, lol. I removed the stable release and now the add-on allows me to install from either stable or edge. Fantastic, thank you! |
I tried to install the EDGE version, for me |
Hi @pisolofin, turns out my SQLite Web auto-upgraded to 99c6355 but it works fine for me with and without spaces in the query. |
Oh you’re right. I hadn't even noticed that query spot on the main page, because I use HA on my phone most of the time. I also noticed that if you do a multiline query it does a 400 bad request, so it looks like that still does a GET request there. |
@pisolofin I’ve commented on the SQLite Web issue that's linked to this ticket and will see what happens. |
Yes my mistake, this is now fixed in 0.6.3 - the index page query form was still using GET and has now been switched to use POST. |
Oh, I can see a previous pull request that tried fixing some URLs in #260. Adding sqlite-web supports providing a base URL with Perhaps: --url-prefix $(bashio::addon.ingress_entry) I might try it out later. |
Sounds good, feel free to PR that @pearj 👍 ../Frenck |
@HansRemmerswaal It has been fixed on dev. Should be part of the next release, currently testing out edge builds on various platforms. |
Sorry, I was to fast :) Minutes ago the update arrived and I can confirm all is working fine now. |
No worries! Thanks for the confirmation ❤️ |
I'm failing to run any queries from the SQLite Web interface, everything returns "400: Bad Request", e.g. the queries listed here such as:
The addon itself seems to be configured properly, there's nothing in the addon log that looks like an error to me and the web console shows it found /config/home-assistant_v2.db with 13 tables, 20 indexes and 2GB size.
But the HA Core logs show:
Log:
Thanks!
The text was updated successfully, but these errors were encountered: