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

Improve error reporting #2423

Merged
merged 25 commits into from
Jun 16, 2017
Merged

Improve error reporting #2423

merged 25 commits into from
Jun 16, 2017

Conversation

matthid
Copy link
Member

@matthid matthid commented Jun 15, 2017

This improves output and internal error propagation in the NuGet-RequestVersions code.
The goal is to output in the error case which urls where requested and what reponse we got from them...

For now this is WIP, because I think there might be some cases now where we print way too much info (in the non-verbose case).

Copy link
Member Author

@matthid matthid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see what the CI says.

static member Choice(tasks : Async<'T option> seq) = async {
static member map f a =
async { return f a }
static member tryFind (f : 'T -> bool) (tasks : Async<'T> seq) = async {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interesting API.
It is almost like Async.Choice, but will return all the started tasks and an index which one matched the given function.

@@ -560,7 +555,7 @@ let downloadFromUrl (auth:Auth option, url : string) (filePath: string) =
do! task
with
| exn ->
failwithf "Could not download from %s%s Message: %s%s" url Environment.NewLine exn.Message (innerText exn)
raise <| Exception(sprintf "Could not download from '%s'" url, exn)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We almost never should do failwithf in a general with exn -> clause, not even when we embed the message (like here)...
I really think F# should make this more easy (with some syntax), even the F# compiler is doing it wrong everywhere

/cc @dsyme any ideas?
maybe allowing to use comma in combination with failwithf "some message", innerException

@@ -612,11 +606,12 @@ let safeGetFromUrl (auth:Auth option, url : string, contentType : string) =
#endif
use _ = Profile.startCategory Profile.Category.NuGetRequest
let! raw = client.DownloadStringTaskAsync(uri) |> Async.AwaitTask
return Some raw
return FSharp.Core.Result.Ok raw
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I should use full-out exceptions everywhere :/

@matthid matthid changed the title [WIP] Improve error reporting Improve error reporting Jun 15, 2017
@matthid
Copy link
Member Author

matthid commented Jun 15, 2017

This is how a failure looks now:

Paket failed with:
-> AggregateException: Could not find versions for package Argu on https://www.myget.org/F/paket-test.
-> AggregateException: Source 'https://www.myget.org/F/paket-test' yielded no results
	 - Request 'https://www.myget.org/F/paket-test/FindPackagesById()?semVerLevel=2.0.0&id='Argu'' finished with error
	-> Could not retrieve data from 'https://www.myget.org/F/paket-test/FindPackagesById()?semVerLevel=2.0.0&id='Argu''
	-> WebException: The remote server returned an error: (401) Unauthorized.
	 - Request 'https://www.myget.org/F/paket-test/Packages?semVerLevel=2.0.0&$filter=tolower(Id) eq 'argu'' finished with error
	-> Could not retrieve data from 'https://www.myget.org/F/paket-test/Packages?semVerLevel=2.0.0&$filter=tolower(Id) eq 'argu''
	-> WebException: The remote server returned an error: (401) Unauthorized.

These changes also show that the random failure we get sometimes is apparently another mono bug:

Paket failed with:
-> AggregateException: Could not find versions for package WebSharper on https://www.nuget.org/api/v2.
-> AggregateException: Source 'https://www.nuget.org/api/v2' yielded no results
	 - Request 'https://www.nuget.org/api/v2/FindPackagesById()?semVerLevel=2.0.0&id='WebSharper'' finished with error
	-> Could not retrieve data from 'https://www.nuget.org/api/v2/FindPackagesById()?semVerLevel=2.0.0&id='WebSharper''
	-> WebException: Error: SecureChannelFailure (Ssl error:100000f7:SSL routines:OPENSSL_internal:WRONG_VERSION_NUMBER
	     at /tmp/buildd/mono-5.0.1.1/external/boringssl/ssl/tls_record.c:217)
	-> MonoBtlsException: Ssl error:100000f7:SSL routines:OPENSSL_internal:WRONG_VERSION_NUMBER
	     at /tmp/buildd/mono-5.0.1.1/external/boringssl/ssl/tls_record.c:217
	 - Request 'https://www.nuget.org/api/v2/Packages?semVerLevel=2.0.0&$filter=tolower(Id) eq 'websharper'' finished with error
	-> Could not retrieve data from 'https://www.nuget.org/api/v2/Packages?semVerLevel=2.0.0&$filter=tolower(Id) eq 'websharper''
	-> WebException: Error: TrustFailure (Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED
	     at /tmp/buildd/mono-5.0.1.1/external/boringssl/ssl/handshake_client.c:1132)
	-> MonoBtlsException: Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED
	     at /tmp/buildd/mono-5.0.1.1/external/boringssl/ssl/handshake_client.c:1132

@matthid
Copy link
Member Author

matthid commented Jun 15, 2017

https://github.com/mono/boringssl/blob/mono/ssl/s3_both.c#L363

https://github.com/mono/boringssl/blob/mono/ssl/s3_both.c#L291

The record length is a 16-byte value and is formatted in network order.

In theory, this means that a single record can be up to 65,535 (2^16 -1) bytes in length. The TLSv1 RFC2246 states that the maximum length is 16,383 (2^14 -1) bytes. Microsoft products (Microsoft Internet Explorer and Internet Information Services) are known to exceed these limits.

http://www.cisco.com/c/en/us/support/docs/security-vpn/secure-socket-layer-ssl/116181-technote-product-00.html

Nice

@matthid
Copy link
Member Author

matthid commented Jun 15, 2017

Note that

1) Error : Paket.IntegrationTests.ConvertFromNuGetSpecs.#1217 should replace packages.config files in project
System.Exception : Paket failed with:
-> Exception: There was a version conflict during package resolution.
     Conflict detected:
      - Dependencies file requested package Newtonsoft.Json: 7.0.1
      - Available versions:
        - (10.0.2, [https://www.nuget.org/api/v2])
       ... snip
        - (8.0.1-beta1, [https://www.nuget.org/api/v2])
        - (7.0.1, [https://dotnet.myget.org/F/cli-deps; https://www.nuget.org/api/v2])
        - (7.0.1-beta3, [https://www.nuget.org/api/v2])
        - (7.0.1-beta2, [https://www.nuget.org/api/v2])
        - (7.0.1-beta1, [https://www.nuget.org/api/v2])
        - (6.0.8, [https://www.nuget.org/api/v2])
       ... snip
        - (3.5.8, [https://www.nuget.org/api/v2])
   
     Please try to relax some conditions or resolve the conflict manually (see http://fsprojects.github.ioPaket/nuget-dependencies.html#Use-exactly-this-version-constraint).

Is explained by the mono bug as well:
I think the request to GetPackageDetails was failing.
Paket needs to improve this error message to include this (important) detail...

@matthid
Copy link
Member Author

matthid commented Jun 15, 2017

There are so many more places where with _ -> is used throughout the paket code base, but I'm happy with this subset for now as especially in the NuGet request logic it was often hard to figure out what was going on.

…es in the final exception print (might be useful for single tests or to tell people to get better bug reports).
@forki
Copy link
Member

forki commented Jun 16, 2017

is this ready?

@forki forki merged commit 4904b5a into master Jun 16, 2017
@forki forki deleted the improve_error_reporting branch June 16, 2017 08:15
@forki
Copy link
Member

forki commented Jun 16, 2017

thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants