This is an automated email from the ASF dual-hosted git repository.
bamaer pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/main by this push:
new 214b524261 Prompt for credentials when a Git fetch needs
authentication (#9183)
214b524261 is described below
commit 214b524261fcb5472f64fc08bb25fb72ccd28fea
Author: Ankit Garg <[email protected]>
AuthorDate: Sun Nov 1 10:55:40 2026 +0530
Prompt for credentials when a Git fetch needs authentication (#9183)
* Prompt for credentials when a Git fetch needs authentication
Fixes #9133
* Do not prompt for credentials from the automatic Git fetch timer
The timer runs off the SWT UI thread, so opening a credentials dialog there
fails with an invalid thread access error. Only the manual Fetch prompts now.
---
.../java/org/apache/hop/git/GitPerspective.java | 3 +-
.../main/java/org/apache/hop/git/model/UIGit.java | 32 ++++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git
a/plugins/misc/git/src/main/java/org/apache/hop/git/GitPerspective.java
b/plugins/misc/git/src/main/java/org/apache/hop/git/GitPerspective.java
index bc113928d9..7e5fc0b1f9 100644
--- a/plugins/misc/git/src/main/java/org/apache/hop/git/GitPerspective.java
+++ b/plugins/misc/git/src/main/java/org/apache/hop/git/GitPerspective.java
@@ -778,7 +778,8 @@ public class GitPerspective implements IHopPerspective {
return;
}
- uiGit.fetch();
+ // Runs on the timer thread: never open a credentials dialog from here
+ uiGit.fetch(false);
if (hopGui != null && !hopGui.getDisplay().isDisposed()) {
hopGui.getDisplay().asyncExec(() -> refresh(false));
diff --git a/plugins/misc/git/src/main/java/org/apache/hop/git/model/UIGit.java
b/plugins/misc/git/src/main/java/org/apache/hop/git/model/UIGit.java
index 6843c00913..abef52b96a 100644
--- a/plugins/misc/git/src/main/java/org/apache/hop/git/model/UIGit.java
+++ b/plugins/misc/git/src/main/java/org/apache/hop/git/model/UIGit.java
@@ -827,12 +827,44 @@ public class UIGit extends VCS {
}
public boolean fetch() throws HopException {
+ return fetch(true);
+ }
+
+ /**
+ * Fetch from the remote.
+ *
+ * @param promptForCredentials whether an authentication failure may open a
credentials dialog.
+ * Pass false when not running on the UI thread, for example from the
automatic fetch timer.
+ */
+ public boolean fetch(boolean promptForCredentials) throws HopException {
if (!hasRemote()) {
throw new HopException("There is no remote set up to fetch from. Please
set this up first.");
}
try {
git.fetch().setCredentialsProvider(credentialsProvider).setCheckFetchedObjects(true).call();
+ } catch (TransportException e) {
+ if (e.getMessage()
+ .contains(
+
CONST_AUTHENTICATION_IS_REQUIRED_BUT_NO_CREDENTIALS_PROVIDER_HAS_BEEN_REGISTERED)
+ || e.getMessage()
+ .contains(CONST_NOT_AUTHORIZED)) { // when the cached credential
does not work
+ if (!promptForCredentials) {
+ throw new HopException("There was an error doing a git fetch", e);
+ }
+ if (e.getMessage().contains(CONST_NOT_AUTHORIZED)) {
+ new ErrorDialog(
+ HopGui.getInstance().getShell(),
+ "Git Error",
+ "Error Authenticating to Git service",
+ e);
+ }
+ if (promptUsernamePassword()) {
+ return fetch(true);
+ }
+ } else {
+ throw new HopException("There was an error doing a git fetch", e);
+ }
} catch (Exception e) {
throw new HopException("There was an error doing a git fetch", e);
}