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

Workspace Templates: show error when fetching templates from Github #6440

Conversation

chrisrueger
Copy link
Contributor

@chrisrueger chrisrueger commented Jan 23, 2025

In this PR

This PR is about error handling the following two wizards:

image

This shows an ErrorDialog the UI when there are problems fetching from Github. The error message also includes a hint to https://bnd.bndtools.org/instructions/connection-settings.html because sometimes you have a ~/.m2/settings.xml with some credentials which can lead to "Bad Credentials" http errors from the Github API, but before this fix you had no idea what was going on, because the UI was blank and the existance of ~/.m2/settings.xml is easily forgotten

The message reads (wording improvements welcome):

Failed to load from template loader (Load workspace templates from GitHub repositories) See Error Log for stack trace:
java.io.IOException: Error (HTTP 520) - no response: TaggedData [tag=, code=520, modified=Thu Jan 01 00:59:59 CET
1970, url=https://api.github.com/repos/bndtools/bndtools.workspace.min, state=OTHER] (Check https://bnd.bndtools.org/instructions/connection-settings.html in case of connection or authentication errors.)

image

Eclipse Error Log tab:

image

At least now you see that something is wrong and also get some information.
Before this it was completely unknown, since the list of templates just appeared empty.

Last but not least, I added the same ErrorDialog also to the (new) Template Fragment Wizard... which can suffer from the same HTTP connection problems. Now the user sees an error dialog too and knows what's going on

This shows "some" error in the UI when there are problems fetching from Github.
The error message also includes a hint to https://bnd.bndtools.org/instructions/connection-settings.html because sometimes you have a ~/.m2/settings.xml with some credentials which can lead to "Bad Credentials" http errors from the Github API, but before this fix you had no idea what was going on, because the UI was blank and the existance of ~/.m2/settings.xml is easily forgotton

Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
@chrisrueger
Copy link
Contributor Author

@peterkir could you have a look and see what the output is in your error case with the incorrect credentials in ~/.m2/settings.xml

instead of abusing the description field.
this seems better suited to display information about an exception.

Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
@chrisrueger
Copy link
Contributor Author

chrisrueger commented Jan 26, 2025

Build error seems to be because of a http error e.g. when accessing stuff from https://download.eclipse.org/ they seem to have maintanance https://www.eclipsestatus.io/

I will retry later

@chrisrueger chrisrueger changed the title show error when fetching templates from Github Workspace Templates: show error when fetching templates from Github Jan 26, 2025
I noticed it does not used in the final display of the ErrorDialog.

Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
since the same http errors can happen there too, so the user should notice that with info whats going wrong

Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
@chrisrueger chrisrueger requested a review from peterkir January 26, 2025 20:07
@chrisrueger chrisrueger self-assigned this Jan 26, 2025
@peterkir
Copy link
Contributor

Still seeing no error message inside the client when pressing next button on "Setup Bnd Workspace" page.
image
The empty template is coming
image
inside the error log the following error message/exception is coming.

2025-01-28 08:44:45,926 [Worker-8: Executing the early startup extensions] INFO  a.b.c.settings.ConnectionSettings - [ConnectionSettings] Read from file: C:\Users\peter\.m2\settings.xml (See https://bnd.bndtools.org/instructions/connection-settings.html for more information)
2025-01-28 08:45:18,679 [HttpClient,https://api.github.com/repos/bndtools/bndtools.workspace.min] INFO  a.bnd.build.LoggingProgressPlugin - Download https://api.github.com/repos/bndtools/bndtools.workspace.min
2025-01-28 08:45:19,206 [Progress Runner] ERROR org.eclipse.equinox.logger - Failed to load from template loader: Load workspace templates from GitHub repositories
org.osgi.util.promise.FailedPromisesException: java.io.IOException: java.lang.NullPointerException: Cannot invoke "java.io.InputStream.available()" because "in" is null
	at org.osgi.util.promise.PromiseFactory$All.run(PromiseFactory.java:362)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.io.IOException: java.lang.NullPointerException: Cannot invoke "java.io.InputStream.available()" because "in" is null
	at org.bndtools.templating.jgit.Cache.download(Cache.java:58)
	at org.bndtools.templating.jgit.GitHub.lambda$0(GitHub.java:32)
	at org.osgi.util.promise.DeferredPromiseImpl$Submit.run(DeferredPromiseImpl.java:755)
	... 3 common frames omitted
Caused by: java.lang.NullPointerException: Cannot invoke "java.io.InputStream.available()" because "in" is null
	at aQute.lib.io.ByteBufferOutputStream.write(ByteBufferOutputStream.java:77)
	at aQute.lib.io.IO.copy(IO.java:410)
	at aQute.lib.io.IO.read(IO.java:733)
	at org.bndtools.templating.jgit.Cache.download(Cache.java:31)
	... 5 common frames omitted

@chrisrueger
Copy link
Contributor Author

Caused by: java.io.IOException: java.lang.NullPointerException: Cannot invoke "java.io.InputStream.available()" because "in" is null
	at org.bndtools.templating.jgit.Cache.download(Cache.java:58)

@peterkir I believe you are not using the code of this PR. The line Cache.java:58 in the stacktrace does not do this in this PR:

image

I actually tried to handle the null inputstream in line 32 and line 50

Copy link
Contributor

@peterkir peterkir left a comment

Choose a reason for hiding this comment

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

image

@peterkir
Copy link
Contributor

Thx. Error message is highly appreciated

@chrisrueger chrisrueger merged commit 0e76ec6 into bndtools:master Jan 31, 2025
9 checks passed
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