-
-
Notifications
You must be signed in to change notification settings - Fork 345
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
Fail on http status codes >=300 for cURL downloads #2879
Conversation
As per https://github.com/masroore/CurlSharp/blob/f9da9aefbc2e26e7ad9e1a242a45e9277b1fc82d/CurlSharp/Enums/CurlOption.cs#L224-L229. This should prevent download errors being concealed.
How will this affect GUI? Previously |
Do we know which mods are affected? Are they the same ones? I don't note any bulk issues, so that wouldn't lead me to think it was rate limiting. The couple I've checked are being redirected. In theory you can just run netkan over the file and get the same result. |
Ahh, so happening pre-bot changeover. Weird.
I could set the inflator to run with debugging for a run and see if we can catch it in more detail. |
Valid concern. The way the method was structured with all the try-catch-throws definitely advertised possible exceptions. But if everything building on it accounts for that is a different question. I'm going to take a look.
It has been previously, but the last few days (maybe since the new infrastructure) they are always the same (or at least mostly). It's weird. |
So what I found:
Besides some occurrences in netkan and the upgrade command, exceptions during DownloadText should be handled nicely. |
OK, let's see what we get... |
Should the bot already update itself or not? |
I thought it would update itself, yes. @techman83 ? |
Only if it's crashing completely. The cake stuff I was futzing around with after work was trying to solve this bit. I've got the permissions sorted out, but I need three build to call Docker Run, exposing the AWS keys as secret parameters. The doco didn't have any examples and my C# is way too rusty! I'll make a coffee and kick the inflator |
It IS an 403 error. The exact response should be found in the log, but I highly suspect throttling reasons. |
Motivation
The NetKAN Inflator service fails from time to time at some mods with the error message
for GitHub hosted mods. It appears to happen in batches.
It must be this line that throws:
CKAN/Netkan/Sources/Github/GithubApi.cs
Lines 42 to 46 in 05406ba
So the answer the bot gets for the API call is not what it expects (a JSON array).
I suspect the answer it gets is a 403 status code telling that the bot is throttled by GitHub (see https://developer.github.com/v3/#rate-limiting).
However, I can't be sure, because errors that might be thrown during/after the download are hidden by the curl fallback mechanism.
.NETs WebClient throws WebExceptions for non-success status codes (I guess >= 400 or 300, couldn't find relevant documentation).
CurlSharp doesn't by default, but behaves as nothing happened and returns the message content.
Changes
I changed the curl download logic to behave more like the native one, that means "failing" if the status code is >= 300.
https://github.com/masroore/CurlSharp/blob/f9da9aefbc2e26e7ad9e1a242a45e9277b1fc82d/CurlSharp/Enums/CurlOption.cs#L224-L229
(However redirects still work!)
Failing means, that the
CurlCode
returned won't beOK
.We use this as an indication to throw a (Web)Exception.
This should propagate request errors upwards, and NetKAN's GitHubApi class will throw the original webexception instead of an obscure json error.
With some luck, this tells us what is wrong with GitHub API requests.
For testing, you can place something like this in
CKAN-netkan/program.cs/Main()
: