From 71ebddc270154c38010dfd214c9116887246ae8f Mon Sep 17 00:00:00 2001 From: rostislav Date: Mon, 5 Jan 2026 12:45:40 +0200 Subject: [PATCH] feat: Add GitLab personal/repository token support in VCS connection handling --- .../handler/processor/AskCommandProcessor.java | 14 +++++++++++--- .../handler/processor/ReviewCommandProcessor.java | 14 +++++++++++--- .../processor/SummarizeCommandProcessor.java | 14 +++++++++++--- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/generic/handler/processor/AskCommandProcessor.java b/java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/generic/handler/processor/AskCommandProcessor.java index ea8a7559..68b90be2 100644 --- a/java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/generic/handler/processor/AskCommandProcessor.java +++ b/java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/generic/handler/processor/AskCommandProcessor.java @@ -361,12 +361,20 @@ private AskRequest buildAskRequest( } } else if (vcsConnection.getConnectionType() == EVcsConnectionType.APP) { accessToken = tokenEncryptionService.decrypt(vcsConnection.getAccessToken()); + } else if (vcsConnection.getConnectionType() == EVcsConnectionType.PERSONAL_TOKEN || + vcsConnection.getConnectionType() == EVcsConnectionType.REPOSITORY_TOKEN) { + // For GitLab personal/repository tokens, get the token from config + if (vcsConnection.getConfiguration() instanceof org.rostilos.codecrow.core.model.vcs.config.gitlab.GitLabConfig gitLabConfig) { + accessToken = gitLabConfig.accessToken(); + } } // Determine VCS provider string - String vcsProvider = vcsConnection.getProviderType() == EVcsProvider.GITHUB - ? "github" - : "bitbucket_cloud"; + String vcsProvider = switch (vcsConnection.getProviderType()) { + case GITHUB -> "github"; + case GITLAB -> "gitlab"; + default -> "bitbucket_cloud"; + }; // Build analysis context string String analysisContext = contextData.analysisInfo(); diff --git a/java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/generic/handler/processor/ReviewCommandProcessor.java b/java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/generic/handler/processor/ReviewCommandProcessor.java index 9dc086cf..85f1582d 100644 --- a/java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/generic/handler/processor/ReviewCommandProcessor.java +++ b/java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/generic/handler/processor/ReviewCommandProcessor.java @@ -171,12 +171,20 @@ private ReviewRequest buildReviewRequest(Project project, WebhookPayload payload } } else if (vcsConnection.getConnectionType() == EVcsConnectionType.APP) { accessToken = tokenEncryptionService.decrypt(vcsConnection.getAccessToken()); + } else if (vcsConnection.getConnectionType() == EVcsConnectionType.PERSONAL_TOKEN || + vcsConnection.getConnectionType() == EVcsConnectionType.REPOSITORY_TOKEN) { + // For GitLab personal/repository tokens, get the token from config + if (vcsConnection.getConfiguration() instanceof org.rostilos.codecrow.core.model.vcs.config.gitlab.GitLabConfig gitLabConfig) { + accessToken = gitLabConfig.accessToken(); + } } // Determine VCS provider string - String vcsProvider = vcsConnection.getProviderType() == EVcsProvider.GITHUB - ? "github" - : "bitbucket_cloud"; + String vcsProvider = switch (vcsConnection.getProviderType()) { + case GITHUB -> "github"; + case GITLAB -> "gitlab"; + default -> "bitbucket_cloud"; + }; Long prId = payload.pullRequestId() != null ? Long.parseLong(payload.pullRequestId()) diff --git a/java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/generic/handler/processor/SummarizeCommandProcessor.java b/java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/generic/handler/processor/SummarizeCommandProcessor.java index aa9b1b2f..1b8a7ef2 100644 --- a/java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/generic/handler/processor/SummarizeCommandProcessor.java +++ b/java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/generic/handler/processor/SummarizeCommandProcessor.java @@ -286,12 +286,20 @@ private SummarizeRequest buildSummarizeRequest( } } else if (vcsConnection.getConnectionType() == EVcsConnectionType.APP) { accessToken = tokenEncryptionService.decrypt(vcsConnection.getAccessToken()); + } else if (vcsConnection.getConnectionType() == EVcsConnectionType.PERSONAL_TOKEN || + vcsConnection.getConnectionType() == EVcsConnectionType.REPOSITORY_TOKEN) { + // For GitLab personal/repository tokens, get the token from config + if (vcsConnection.getConfiguration() instanceof org.rostilos.codecrow.core.model.vcs.config.gitlab.GitLabConfig gitLabConfig) { + accessToken = gitLabConfig.accessToken(); + } } // Determine VCS provider string - String vcsProvider = vcsConnection.getProviderType() == EVcsProvider.GITHUB - ? "github" - : "bitbucket_cloud"; + String vcsProvider = switch (vcsConnection.getProviderType()) { + case GITHUB -> "github"; + case GITLAB -> "gitlab"; + default -> "bitbucket_cloud"; + }; return new SummarizeRequest( project.getId(),