Skip to content
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

piwik.php is returning 400 #7850

Closed
opnoack opened this issue May 6, 2015 · 24 comments
Closed

piwik.php is returning 400 #7850

opnoack opened this issue May 6, 2015 · 24 comments
Assignees
Labels
answered For when a question was asked and we referred to forum or answered it. Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change.
Milestone

Comments

@opnoack
Copy link

opnoack commented May 6, 2015

I have updated piwik to the latest version a couple days ago. I am monitoring the http return code of the piwik.php file. After the update I receive 400 instead of 200 before. There is no error logged in the webserver since the returncode comes directly from the script.

piwik

@luciopileggi
Copy link

Same problem on my installation... The drupal piwik module is broken because of this problem https://www.drupal.org/node/2483815

@tsteur
Copy link
Member

tsteur commented May 6, 2015

Yes, since Piwik 2.13.0 we do return a HTTP 400 (Bad request) when requesting piwik.php without any parameters since it cannot track anything without any parameters. We missed to document/announce that, I'm very sorry about that. I will add this now.

Can you use eg piwik.php?rec=0 instead?

I'm wondering for what kind of checks you use piwik.php?

tsteur added a commit that referenced this issue May 6, 2015
@tsteur tsteur added the answered For when a question was asked and we referred to forum or answered it. label May 6, 2015
@tsteur tsteur added this to the 2.13.1 milestone May 6, 2015
@tsteur tsteur self-assigned this May 6, 2015
@tsteur
Copy link
Member

tsteur commented May 6, 2015

Is this maybe also related to #7810 (Stable page for ELB health check)?

@tsteur tsteur modified the milestones: Piwik 2.14.0, 2.13.1 May 6, 2015
@opnoack
Copy link
Author

opnoack commented May 7, 2015

Thanks for your reply. Unfortunately that doesn't solve the problem for me. Still receiving 400 code with parameters.

@tsteur
Copy link
Member

tsteur commented May 7, 2015

True, this morning I got a 200 when I tried it but now getting a 400. Weird... What exactly do you want to monitor / check by calling piwik.php? Is it a requirement that it is the piwik.php? or could it just be any file?

@opnoack
Copy link
Author

opnoack commented May 7, 2015

I think it could be any file. We're just monitoring the return code with a monitoring system and since it worked all the time there was no need to change it. Is there another way to verify that the piwik installation is working?

@tsteur
Copy link
Member

tsteur commented May 7, 2015

@mattab what do we test for in our monitoring? I think we do test for something?

Also you might be interested in #7810 as well

@opnoack
Copy link
Author

opnoack commented May 7, 2015

Well the old behaviour was okay for us, I don't see the point in changing the default return code to 400 for the piwik.php.

To test the application it must be accessible via http and the application must be able to establish a database connection (and maybe even run a query on the database). The processes for web- and database-server are monitored separately.

@tsteur
Copy link
Member

tsteur commented May 7, 2015

and the application must be able to establish a database connection (and maybe even run a query on the database)

Just FYI: I don't think piwik.php does this when there are no URL parameters but I'm not 100% sure. As another user asked for it in the other issue maybe it actually makes sense to provide an "API" / file for this that tests different kind of things. index.php cannot be really used since it might redirect when there is an update to execute. Waiting for feedback of @mattab for now

@alexhass
Copy link

alexhass commented May 7, 2015

Users need to enter the url to their piwik installation in Drupal. The only way to verify that they entered the correct url to piwik is doing a http request to piwik and verify that the tracker path is correct. Therefore I have chosen piwik.php with status code 200 in past. Blocking request to this php file with status 400 is bad idea as this has broken now ~17.000 installations.

I can change this in a future release, but now all current installations are broken and to whatever I'm changing it now, you may break it again.

@tsteur tsteur added Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change. and removed answered For when a question was asked and we referred to forum or answered it. labels May 7, 2015
@tsteur
Copy link
Member

tsteur commented May 7, 2015

OK, what I will do for now is to return a HTTP 200 in case a GET piwik.php is performed without any query or POST parameters. EG GET http://example.org/piwik.php will return a HTTP 200. Is that okay?

Next step would be at some point to actually provide a file or API for this maybe. Waiting for response of @mattab re my previous question.

I reckon we can close this issue as soon as the PR is merged and discuss everything following in #7810

@alexhass
Copy link

alexhass commented May 7, 2015

The drupal module only makes a GET - no POST. Solution sounds fine. Thanks.

Looking forward to a reliable and future safe solution.

@alexhass
Copy link

alexhass commented May 7, 2015

Aside - how soon can we expect a release with this fix included? And how about adding a comment to the code to explain the reason so it does not break again?

@tsteur
Copy link
Member

tsteur commented May 7, 2015

I added a test and explained it there to make sure it won't be removed again and explained it there.

I'm not sure how soon we can expect it. Usually we release a new version around the 15th of a month. Possibly this will be the case. @mattab can tell more re this.

@mattab
Copy link
Member

mattab commented May 14, 2015

Just FYI: I don't think piwik.php does this when there are no URL parameters but I'm not 100% sure. As another user asked for it in the other issue maybe it actually makes sense to provide an "API" / file for this that tests different kind of things. index.php cannot be really used since it might redirect when there is an update to execute. Waiting for feedback of @mattab for now

Created an issue to discuss How do I monitor that Piwik service is up? #7904

@tsteur
Copy link
Member

tsteur commented May 14, 2015

Why not reuse #7810 ? Or is that something different?

@mattab mattab added the answered For when a question was asked and we referred to forum or answered it. label Jun 24, 2015
@gittoar
Copy link

gittoar commented Jul 16, 2015

Hello, why is a HEAD-request not allowed?

@tsteur
Copy link
Member

tsteur commented Jul 16, 2015

what do you mean by it's not allowed? I haven't tested it but should work in general?

@gittoar
Copy link

gittoar commented Jul 16, 2015

OK, what I will do for now is to return a HTTP 200 in case a GET piwik.php is performed without any query or POST parameters. EG GET http://example.org/piwik.php will return a HTTP 200. Is that okay?

So, you have only allowed a GET without any parameters but not a HEAD.

Examples:

telnet 127.0.0.1 80
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
GET /piwik.php
Piwik is a free/libre web analytics that lets you keep control of your data.Connection closed by foreign host.

telnet 127.0.0.1 80
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
HEAD /piwik.php

<title>400 Bad Request</title>

Bad Request

Your browser sent a request that this server could not understand.

Connection closed by foreign host.

@tsteur
Copy link
Member

tsteur commented Jul 16, 2015

OK I get it. The code checks for GET specifically. Do you mind creating a new issue for this as this one is already resolved and the HEAD request is a different feature/bug? We should maybe always allow HEAD and GET interchangably

@ghost
Copy link

ghost commented Jul 22, 2015

Just to let you know the issue is still there with the upgrade to 2.14.1 and is related to database.
The real issue I get is:
Error query: fetch() failed: Unknown column 'visit_first_action_time' in 'field list' : ...
but the error is masked with http error code 400.
So or the update didn't update the database schema or there's a typo in the field name in the code .

@gittoar
Copy link

gittoar commented Jul 22, 2015

A new issue for HEAD-requests and the http-response-code 400 was created: #8397

@frictionel
Copy link

With Piwik 2.14.2, using the proxy-script, I saw a lot of "400 Bad Request" today. Which is the second time after 2015-07-14.

The request URLs look legit. First I thought it might be a problem with the database because it had connection problems around the same time but when I rerequest one of the URLs now I still get the error without db connection issues.

Can there be another reason besides missing parameters?

@tsteur
Copy link
Member

tsteur commented Jul 27, 2015

It can have many different reasons. For example if the requested website can't be found (should not be the case here) or if for any other reason there are no logged requests. I'd recommend to create a new issue or to ask in forum

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it. Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change.
Projects
None yet
Development

No branches or pull requests

7 participants