scarvalhojr / aoc-cli

Advent of Code command-line tool
MIT License
249 stars 17 forks source link

HTTP status server error (500 Internal Server Error) #5

Closed JSlaig closed 2 years ago

JSlaig commented 2 years ago

The day before yesterday I setted up on my laptop, after setting the session file and everything the same way I did on my desktop. I get this error, at first I thought it could be due to advent of code's website, but the specific url's for which the client throws the error are working with no issues on my browser tabs. Can't say if it is currently working on my desktop neither where the problem is.

scarvalhojr commented 2 years ago

Can you give me more details? Is it failing every time with the same error? Does it fail on every operation (read, download, submit)? Can you share the full command line and output? What are your environments like (Linux, Windows, Mac) on both of your machines? Which Rust version do you have installed and how did you install it - rustup? How did you install aoc-cli: cargo install aoc-cli?

You can do a simple test to make sure you can reach adventofcode.com and your session cookie is okay using curl:

curl -v -O --cookie "session=<contents of your session cookie file>" https://adventofcode.com/2021/day/25/input
JSlaig commented 2 years ago

Sure, it fails on every command provided with the same error. The full command and output goes like this:

aoc read -y 2021 -d 5

Loaded session cookie from "C:\Users\Chechu.adventofcode.session".

Error: "HTTP status server error (500 Internal Server Error) for url (https://adventofcode.com/2021/day/5)"

My environments are both windows, the one working is on a win 11 desktop pc and current (the one which is failing is a windows 10 laptop), I must point out the file created in the win 11 desktop was made with the touch command via a linux subsystem. In the current device the file was created via powershell with the command:

New-Item .adventofcode.session

The file was created either in my harddrive root and in my default user home dir to test which one was the right one.

My version of rust is the stable release 1.57.0, and I installed rust via the executable file from the rust web and aoc-cli via the commands and steps from the repo.

Lastly, about my session cookie:

curl -v -O --cookie "session=<session-key>" https://adventofcode.com/2021/day/25/input

Invoke-WebRequest : No se encuentra ningún parámetro de posición que acepte el argumento 'https://adventofcode.com/2021/day/25/input'. En línea: 1 Carácter: 1

  • curl -v -O --cookie "session=" https://adven ...
  • 
    + CategoryInfo          : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
  • FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

The Invoke-WebRequest translated would go like this:

There is no position parameter found that accepts the argument 'https://adventofcode.com/2021/day/25/input'.

scarvalhojr commented 2 years ago

Looks like Powershell is intercepting your command and not calling curl - instead it's running Invoke-WebRequest, which has different command line parameters. I'm not a Windows user but perhaps try running curl from a normal shell (rather than Powershell)?

The HTTP 500 error is strange. It's either the adventofcode.com server crashing (unlikely) or something is happening between your laptop and the HTTP request going out -- perhaps a proxy or VPN? That's why I wanted to see what a curl request would return.

scarvalhojr commented 2 years ago

It looks like a bad cookie can actually result in a 500 error from adventofcode.com:

# curl --cookie "session=badcookie" https://adventofcode.com/2021/day/25

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator at 
 webmaster@localhost to inform them of the time this error occurred,
 and the actions you performed just before this error.</p>
<p>More information about this error may be available
in the server error log.</p>
</body></html>

So most likely your file contains an invalid session cookie. Make sure it is a single line with just a long hex string (do NOT include session=).

@Jsalig00, please check your cookie file and let me know if it resolves.