pschlan / cron-job.org

cron-job.org Open Source project
GNU General Public License v2.0
1.45k stars 251 forks source link

A successfully executed job that receives a 302 response is interpreted as "Failed (HTTP error)" #111

Closed karentamrazyan closed 2 years ago

karentamrazyan commented 2 years ago

the cron job org site interprets a successfully executed job where a website return a 302 HTTP header as "Failed (HTTP error)"

pschlan commented 2 years ago

Usually a 302 status code requires a redirection to complete the job. Since we don’t follow redirects, we assume the execution didn’t finish completely.

Why does your URL return a 302 in case of success?

karentamrazyan commented 2 years ago

This assumption is not very logical.

Here is a list of HTTP response categories:

In my opinion you can only assume that something went wrong if a server returns 4XX or 5XX. Every other HTTP response is technically NOT a failure.

As per this particular case, the job in question successfully passes an authentication and then the server redirects the authenticated visitor to their dashboard. Again, the whole process is failure free, yet your service interprets it as a failure and disables the cron job after a few attempts.

Please, fix it or give us a way to define what is a failure.

pschlan commented 2 years ago

In most cases, jobs by our users get a 302 when the URL redirects to a https version or the www domain etc. Just treating the 3xx as successful would hide an actual problem in that case.

I'll check if I can make this configurable, though, to support your use case as well.

karentamrazyan commented 2 years ago

you could add a checkbox "treat a redirect response as a failed job", which can be on by default.

pschlan commented 2 years ago

This is now available in the "Advanced" tab of the job editor. (Might need to do a forced refresh in the browser to see it.) Thanks for reporting!

karentamrazyan commented 2 years ago

thanks! works like a charm!