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

Unable to sync git repo with no commits #172

Closed
clach04 opened this issue Feb 17, 2024 · 6 comments · Fixed by #180
Closed

Unable to sync git repo with no commits #172

clach04 opened this issue Feb 17, 2024 · 6 comments · Fixed by #180
Labels
bug Something isn't working Git repos Related to Git syncing

Comments

@clach04
Copy link

clach04 commented Feb 17, 2024

  • I have searched for existing issues that may be the same as or related to mine.

Please complete the following information:

Device: Samsung s9plus
Android Version: 10
Orgzly Revived Version: https://github.com/orgzly-revived/orgzly-android-revived/releases/tag/v1.8.17-beta.1

Tried with 2 different servers. Using an RSA key (got different issues with other key type)

Related #150

java.io.IOException: fc.z: git@github.com:clach04/Orgzlytest.git: remote hung up unexpectedly
at w5.f.l(GitRepo.java:60)
at w5.f.n(GitRepo.java:3)
at w5.f.o(GitRepo.java:18)
at com.orgzly.android.ui.repo.git.GitRepoActivity$d.c(GitRepoActivity.kt:9)
at com.orgzly.android.ui.repo.git.GitRepoActivity$d.doInBackground(GitRepoActivity.kt:3)
at android.os.AsyncTask$3.call(AsyncTask.java:378)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
Caused by: fc.z: git@github.com:clach04/Orgzlytest.git: remote hung up unexpectedly
at ec.l.k(FetchCommand.java:137)
at ec.h.r(CloneCommand.java:113)
at ec.h.m(CloneCommand.java:37)
at w5.f.l(GitRepo.java:39)
... 10 more
Caused by: jc.r0: git@github.com:clach04/Orgzlytest.git: remote hung up unexpectedly
at ld.r3$d.(TransportGitSsh.java:32)
at ld.r3.h0(TransportGitSsh.java:3)
at ld.i0.h(FetchProcess.java:61)
at ld.i0.g(FetchProcess.java:24)
at ld.n3.j(Transport.java:104)
at ec.l.k(FetchCommand.java:55)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/management/ReflectionException;
at lb.e.b(ExceptionUtils.java:51)
at wa.c.w6(AbstractSshFuture.java:34)
at v9.e.C6(DefaultAuthFuture.java:3)
at v9.e.r3(DefaultAuthFuture.java:1)
at wa.m.b(VerifiableFuture.java:7)
at wa.i.W5(DefaultVerifiableSshFuture.java:1)
at od.m.k(SshdSession.java:136)
at od.m.m(SshdSession.java:29)
at od.f0.X(SshdSessionFactory.java:28)
at od.f0.d(SshdSessionFactory.java:1)
at ld.h3.K0(SshTransport.java:41)
at ld.r3$d.(TransportGitSsh.java:4)
... 18 more
Caused by: java.lang.ClassNotFoundException: javax.management.ReflectionException
... 30 more

@clach04 clach04 added the bug Something isn't working label Feb 17, 2024
@amberin
Copy link
Member

amberin commented Feb 17, 2024

Thank you. Will look into it tonight.

@amberin amberin added the Git repos Related to Git syncing label Feb 17, 2024
@amberin
Copy link
Member

amberin commented Feb 17, 2024

Are you prompted about accepting the server's public key? (That notification will not show if your phone is in "do not disturb" mode, which is a problem.)

Troubleshooting this is difficult because of the "Failed resolution of: Ljavax/management/ReflectionException" situation. The version of the SSH library which JGit relies on is not Android-aware, and uses an exception class which does not exist on Android. Since JGit does not know the actual root exception, it just gives the generic "remote hung up unexpectedly" error. This is solved in later JGit versions, but those only work with Android 13 or above.

I have tested forcing an upgrade of only the SSH library, but then JGit's SSH code breaks as the interfaces have changed.

The only thing we know for sure is that something goes wrong when establishing the SSH session. In my experience, these "remote hung up" errors are often not caused by Orgzly bugs, but outside factors. There are many things that can go wrong: server public key not being accepted (see above), SSH key was not properly authorized, bad URL, lack of permissions on the remote side, and so on. So make sure to check everything, for instance double check that the same URL works from your computer. But you said you tried two different servers, so... yeah, you have probably double checked already.

@clach04
Copy link
Author

clach04 commented Feb 21, 2024

Sorry for the delayed response.

Are you prompted about accepting the server's public key? (That notification will not show if your phone is in "do not disturb" mode, which is a problem.)

That was definitely it. All the times I tested it was in do not-disturb mode. I re-tested with DnD on and off and once off, I see a prompt and things progress.

Now Sync is an option.. but I get a new error:

Failed to update marker branch

As you might expect the git repo server side is still empty. There is a .git directory locally.

I wasn't sure sure what "marker" is referring to so searching code repo:

<string name="git_sync_error_failed_set_marker_branch">Failed to update marker branch</string>

Looks like creating the branch failed looking at

throw new IOException(context.getString(R.string.git_sync_error_failed_set_marker_branch));

but no detail in the git error returned.

I'm going to play some more (I don't have any precious notes so I can avoid to wipe and retest).

Thank you for taking the time to dig into this and offer advice!

@clach04
Copy link
Author

clach04 commented Feb 21, 2024

https://www.youtube.com/watch?v=r13riaRKGo0 Great Success!

Got this to succeed.

What worked:

Ensure git repo is NOT empty.

I created a file called text.txt with minimal content and pushed that into the server (ended up using "main" as branch name).
Then adding repo to orgzly-revived I only had to change the branch name to match (already had accepted server certificate/fingerprint).

Then the sync worked and ended up with the default .org file sample pushed into remote repo.

What didn't work:

two different git servers with ssh that had empty repos.., which is the default for creating a repo with many (hosted) git servers. For example GitHub.

Not had chance to play any more.

Will see how I get on :-)

So I think this issue is resolved but there are some possible doc issues to come out of this.

@amberin
Copy link
Member

amberin commented Feb 21, 2024

Thank you, this is really valuable and it's an excellent test case if I manage to create some tests.

I had not thought about nor tested this scenario, but as you say, it's super common and expected, so it should definitely be handled gracefully. I suspect it will be an easy fix.

Thanks once again! I wonder how many potential users have run into this...

@amberin amberin changed the title Git clone failure Unable to clone git repo with no commits Feb 21, 2024
@amberin
Copy link
Member

amberin commented Feb 21, 2024

The ssh server key prompt (notification) not showing in DnD mode should also be fixed. I don't know how, but it must be doable. Edit: Created #178.

@amberin amberin changed the title Unable to clone git repo with no commits Unable to sync git repo with no commits Feb 21, 2024
@amberin amberin linked a pull request Feb 21, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Git repos Related to Git syncing
Projects
None yet
2 participants