JetpackDuba / Gitnuro

A FOSS Git multiplatform client for newbies and pros
https://gitnuro.com/
GNU General Public License v3.0
943 stars 46 forks source link

Error alert after push commit #211

Closed CSantosM closed 1 month ago

CSantosM commented 4 months ago

Describe the bug After pushing the commit, a non descriptive error appear. The commit is correctly pushed.

To Reproduce Commit and push

Expected behavior Success message should be appear if the commit has been pushed successfully

Screenshots image

Desktop (please complete the following information):

JetpackDuba commented 4 months ago

Thank for your report!

Can you please share the logs in ~/.local/state/gitnuro/logs please? Remember to obfuscate any confidential information such as repository URLs.

CSantosM commented 4 months ago

Hi, sure. In the logs I can see several errors

2024-05-28 13:28:23 INFO  slf4j:8 - TabViewModel - Changes detected, partial refresh
2024-05-28 13:29:02 ERROR slf4j:16 - TabState - StandaloneCoroutine was cancelled
kotlinx.coroutines.JobCancellationException: StandaloneCoroutine was cancelled; job=StandaloneCoroutine{Cancelling}@509b4856
2024-05-28 13:29:04 INFO  slf4j:8 - TabViewModel - Changes detected in git directory, full refresh
2024-05-28 13:29:04 INFO  slf4j:8 - SharedRepositoryStateMa - Refreshing repository state com.jetpackduba.gitnuro.git.rebase.RebaseInteractiveState$None@266e6573
2024-05-28 13:29:19 INFO  slf4j:8 - SharedRepositoryStateMa - Refreshing repository state com.jetpackduba.gitnuro.git.rebase.RebaseInteractiveState$None@228ea5d9
2024-05-28 13:29:20 INFO  slf4j:8 - TabViewModel - Changes detected in git directory, full refresh
2024-05-28 13:29:20 INFO  slf4j:8 - SharedRepositoryStateMa - Refreshing repository state com.jetpackduba.gitnuro.git.rebase.RebaseInteractiveState$None@266e6573
2024-05-28 13:29:31 ERROR slf4j:16 - TabState - Wrong IV length: must be 16 bytes long
java.security.InvalidAlgorithmParameterException: Wrong IV length: must be 16 bytes long
    at java.base/com.sun.crypto.provider.CipherCore.init(CipherCore.java:443)
    at java.base/com.sun.crypto.provider.AESCipher.engineInit(AESCipher.java:338)
    at java.base/javax.crypto.Cipher.implInit(Cipher.java:871)
    at java.base/javax.crypto.Cipher.chooseProvider(Cipher.java:929)
    at java.base/javax.crypto.Cipher.init(Cipher.java:1444)
    at java.base/javax.crypto.Cipher.init(Cipher.java:1375)
    at com.jetpackduba.gitnuro.credentials.CredentialsCacheRepository.cipherEncrypt(CredentialsCacheRepository.kt:67)
    at com.jetpackduba.gitnuro.credentials.CredentialsCacheRepository.cacheHttpCredentials(CredentialsCacheRepository.kt:34)
    at com.jetpackduba.gitnuro.credentials.CredentialsCacheRepository.cacheHttpCredentials(CredentialsCacheRepository.kt:30)
    at com.jetpackduba.gitnuro.credentials.HttpCredentialsProvider.cacheCredentialsIfNeeded(HttpCredentialsProvider.kt:255)
    at com.jetpackduba.gitnuro.git.remote_operations.HandleTransportUseCase.invoke(HandleTransportUseCase.kt:41)
    at com.jetpackduba.gitnuro.git.remote_operations.PushBranchUseCase$invoke$2.invokeSuspend(PushBranchUseCase.kt:31)
    at com.jetpackduba.gitnuro.git.remote_operations.PushBranchUseCase$invoke$2.invoke(PushBranchUseCase.kt)
    at com.jetpackduba.gitnuro.git.remote_operations.PushBranchUseCase$invoke$2.invoke(PushBranchUseCase.kt)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:169)
    at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
    at com.jetpackduba.gitnuro.git.remote_operations.PushBranchUseCase.invoke(PushBranchUseCase.kt:23)
    at com.jetpackduba.gitnuro.viewmodels.MenuViewModel$push$1.invokeSuspend(MenuViewModel.kt:55)
    at com.jetpackduba.gitnuro.viewmodels.MenuViewModel$push$1.invoke(MenuViewModel.kt)
    at com.jetpackduba.gitnuro.viewmodels.MenuViewModel$push$1.invoke(MenuViewModel.kt)
    at com.jetpackduba.gitnuro.git.TabState$safeProcessing$job$1$2.invokeSuspend(TabState.kt:136)
    at com.jetpackduba.gitnuro.git.TabState$safeProcessing$job$1$2.invoke(TabState.kt)
    at com.jetpackduba.gitnuro.git.TabState$safeProcessing$job$1$2.invoke(TabState.kt)
    at com.jetpackduba.gitnuro.extensions.StateManagementUtilsKt.delayedStateChange(StateManagementUtils.kt:21)
    at com.jetpackduba.gitnuro.git.TabState$safeProcessing$job$1.invokeSuspend(TabState.kt:124)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
2024-05-28 13:29:31 INFO  slf4j:8 - SharedRepositoryStateMa - Refreshing repository state com.jetpackduba.gitnuro.git.rebase.RebaseInteractiveState$None@228ea5d9
2024-05-28 13:29:32 INFO  slf4j:8 - TabViewModel - Changes detected in git directory, full refresh
JetpackDuba commented 4 months ago

Uh it seems that it fails trying to cache the HTTP password. Gitnuro tries to encrypt the password in memory just to reduce the attack surface in case of a memory dump, this process it's what fails, but I'm not sure about the reason.

If you don't mind using your credentials everytime you do a network operation, you can turn off credentials cache in the settings. An alternative would be using Git Credentials Manager or simply SSH.

In any case, thank you for the report, I'll dig further into the issue and get back to you ASAP.

JetpackDuba commented 4 months ago

Not sure how to reproduce the bug but I found some error-prone code that I have replaced with a more rebust implementation. Would you like to test it? :smile:

Not sure if you are using the JAR, Flatpak or a version provided by your distro.

JetpackDuba commented 1 month ago

Hello again. The replacement apparently work as intended! Closing this