Skip to content

fix(mps-sync-plugin): fix switchBranch#2386

Merged
slisson merged 2 commits intomainfrom
fix/switch-branch
Feb 18, 2026
Merged

fix(mps-sync-plugin): fix switchBranch#2386
slisson merged 2 commits intomainfrom
fix/switch-branch

Conversation

@abstraktor
Copy link
Collaborator

  • after switchBranch, we set versionHash=null and then recreate the BindingWorker
  • as a result, BindingWorker.initialVersionHash is null for that target
  • thus, that branch needs to be pulled even though the binding was already active before

@github-actions
Copy link
Contributor

github-actions bot commented Feb 13, 2026

Test Results

  245 files    245 suites   51m 53s ⏱️
1 411 tests 1 400 ✅ 11 💤 0 ❌
1 421 runs  1 410 ✅ 11 💤 0 ❌

Results for commit 9893b77.

♻️ This comment has been updated with latest results.

@dalbrecht1
Copy link

It seems that this change is still necessary for the switchBranch use case but breaks the initial sync of a remote repository. The effect of this change is that when syncing a multi-repo project only a limited number of repos are actually imported.

Perhaps this is just the wrong place for that line of code..

@slisson
Copy link
Member

slisson commented Feb 16, 2026

This PR is supposed to fix the following issue:

io.ktor.client.plugins.ClientRequestException: Client request(POST https://example.com/v2/repositories/myrepo/init) invalid: 403 Forbidden. Text: "{"type":"/problems/forbidden","title":"Forbidden","status":403,"detail":"91320572-687f-4713-b1ea-7b6c923897c9 has no permission 'repository/myrepo/create'"}"
    at io.ktor.client.plugins.DefaultResponseValidationKt$addDefaultResponseValidation$1$1.invokeSuspend(DefaultResponseValidation.kt:54)
    at io.ktor.client.plugins.DefaultResponseValidationKt$addDefaultResponseValidation$1$1.invoke(DefaultResponseValidation.kt)
    at io.ktor.client.plugins.DefaultResponseValidationKt$addDefaultResponseValidation$1$1.invoke(DefaultResponseValidation.kt)
    at io.ktor.client.plugins.HttpCallValidatorKt.HttpCallValidator$lambda$2$validateResponse(HttpCallValidator.kt:110)
    at io.ktor.client.plugins.HttpCallValidatorKt.access$HttpCallValidator$lambda$2$validateResponse(HttpCallValidator.kt:1)
    at io.ktor.client.plugins.HttpCallValidatorKt$HttpCallValidator$2$2.invokeSuspend(HttpCallValidator.kt:129)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
    at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:124)
    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:586)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:820)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:717)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:704)

When a branch doesn't exist the sync plugin tries to create the repository.

- after switchBranch, we set versionHash=null and then recreate the BindingWorker
- as a result, BindingWorker.initialVersionHash is null for that target
- thus, that branch needs to be pulled even though the binding was already active before
Switching to a new branch failed because the plugin tried to create the repository instead of
just creating a new branch from master.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 18, 2026

JVM coverage report

Overall Project 59% -0.02%
Files changed 94.17% 🍏

File Coverage
RepositoriesManager.kt 89.25% 🍏
BindingWorker.kt 85.73% 🍏
ModelClientV2.kt 83.46% -0.04% 🍏
IRepositoriesManager.kt 82.64% 🍏
ModelReplicationServer.kt 78.75% -0.73%
ModelSyncService.kt 72.19% 🍏
IModelClientV2.kt 62.87% 🍏

@RequiresTransaction
fun getVersionHash(branch: BranchReference): String?
suspend fun pollVersionHash(branch: BranchReference, lastKnown: String?): String
suspend fun pollVersionHash(branch: BranchReference, lastKnown: String?): String?

Check warning

Code scanning / detekt

The function pollVersionHash is missing documentation. Warning

The function pollVersionHash is missing documentation.
@slisson slisson merged commit 676d7ef into main Feb 18, 2026
17 checks passed
@slisson slisson deleted the fix/switch-branch branch February 18, 2026 15:37
@slisson
Copy link
Member

slisson commented Feb 19, 2026

🎉 This PR is included in version 18.4.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments