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

Better logs and error messages #25

Merged

Conversation

cyrille-leclerc
Copy link
Contributor

Better logs and error messages. Especially for SSL and invalid credentials.

@cyrille-leclerc
Copy link
Contributor Author

@reviewbybees

@ghost
Copy link

ghost commented Mar 4, 2016

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

@jglick
Copy link
Member

jglick commented Mar 4, 2016

🐝

@jenkinsadmin
Copy link
Member

Thank you for this pull request! Please check this document for how the Jenkins project handles pull requests.

@recena
Copy link
Contributor

recena commented Mar 4, 2016

@cyrille-leclerc Before to merge this one, I'm reviewing this #23 it is related.

@recena
Copy link
Contributor

recena commented Mar 4, 2016

DON NOT MERGE!

return;
}

if (!github.isAnonymous()) {
listener.getLogger().format("Connecting to GitHub using %s%n", CredentialsNameProvider.name(credentials));
listener.getLogger().format("Connecting to %s using %s%n", apiUri == null ? "github.com" : apiUri, CredentialsNameProvider.name(credentials));
Copy link
Contributor

Choose a reason for hiding this comment

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

Use HttpsRepositoryUriResolver.hostnameFromApiUri()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@recena RepositoryUriResolver#hostnameFromApiUri just returns the hostname when I would like to display the entire API URL. I suspect that some people will make a mistake defining the API URL and will be happy to see the entire URL.

BTW I did not catch why GitHubSCMNavigator#apiUri is nullable with a kind of discovery happening latter on.

Copy link
Contributor

Choose a reason for hiding this comment

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

@cyrille-leclerc This only makes sense when you are working with a GHE instance. When you configure an instance, its endpoint has always the same format: http(s)://hostname/api/v3/. For that reason, the important part is the hostname.

@recena
Copy link
Contributor

recena commented Mar 4, 2016

🐜 because there is an explicit method to resolve the hostname from an apiUrl.

@cyrille-leclerc
Copy link
Contributor Author

I would prefer to have the entire API URL including port, URI & protocol rather than just the hostname.

404 invoking github.example.com is less helpful than 404 invoking https://github.example.com/api/v3_I_introduced_a_typo.

@recena
Copy link
Contributor

recena commented Mar 4, 2016

@cyrille-leclerc It should not happen if the form validation for GitHub Enterprise instances is working fine.

@recena
Copy link
Contributor

recena commented Mar 4, 2016

@cyrille-leclerc I don't want to block this PR but my opinion is on the table.

@recena
Copy link
Contributor

recena commented Mar 4, 2016

🐝

@recena
Copy link
Contributor

recena commented Mar 4, 2016

@reviewbybees done

@recena recena closed this Mar 4, 2016
@recena recena reopened this Mar 4, 2016
recena added a commit that referenced this pull request Mar 4, 2016
@recena recena merged commit ebd364e into jenkinsci:master Mar 4, 2016
@cyrille-leclerc
Copy link
Contributor Author

It should not happen

I wish you were with me when I tried to understand why things went wrong in my setup.

I propose that we lower the level of details of the logs once the code stops silently ignoring critical exception like IOException (using catch (IOException) {// ignore because this cannot not happen}) .

FYI even org.kohsuke:github-api silently swallows IOException.

I'll show you how hard it is to findout that an SSL cert is not trusted.

Places where we silently swallow exceptions:

@cyrille-leclerc
Copy link
Contributor Author

@recena thanks for merging! I shared my opinion too :-)

@recena
Copy link
Contributor

recena commented Mar 4, 2016

@cyrille-leclerc I agree with the motivation of your PR, I only recommend to avoid a lot of ternary operators and magic strings like github.com.

If you want we can discuss all these cases when you file the corresponding bugs.

@jglick
Copy link
Member

jglick commented Mar 4, 2016

Generally any code which looks like

} catch (IOException e) {
    // ignore
}

is wrong. You should be logging (perhaps at FINE), or catching a more specific type like FileNotFoundException if you expect the API to be producing a 404 under certain normal conditions.

@jglick
Copy link
Member

jglick commented Mar 4, 2016

I would prefer to have the entire API URL including port, URI & protocol rather than just the hostname.

Agreed.

@recena
Copy link
Contributor

recena commented Mar 4, 2016

@jglick

Generally any code which looks like

Generally is a way to say in the majority cases but when you use GitHub API you will find exceptions.

@ndeloof
Copy link

ndeloof commented Mar 4, 2016

@recena spend few months at support and then you"ll change your mind about silently ignoring API errors.

@recena
Copy link
Contributor

recena commented Mar 4, 2016

@ndeloof Thanks for your advice I never thought about it.

@orrc
Copy link
Member

orrc commented Mar 4, 2016

I'm 100% with you @cyrille-leclerc — I tried using this plugin and got zero feedback about why my config wasn't working, or why my GH Enterprise URL was "wrong".

Thanks for the improvements!

@recena
Copy link
Contributor

recena commented Mar 4, 2016

@orrc Did you file some issue? When did you set the GitHub Enterprise instance the form validation was supported? It was included in 1.1.

@recena
Copy link
Contributor

recena commented Mar 5, 2016

@orrc I saw you comment here. Now, evertything is clear 😵

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