Skip to content

Commit 315f13b

Browse files
fix(workspace): allow adding repos by name for GitLab PAT workspaces
GitLab repos may not be synced yet when manually adding them to monitor. Skip the DB existence check for GITLAB_PAT workspaces — the monitor entry is created with nameWithOwner and the sync will populate the repository entity later.
1 parent 174df1c commit 315f13b

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

server/application-server/src/main/java/de/tum/in/www1/hephaestus/workspace/WorkspaceRepositoryMonitorService.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,17 @@ public void addRepositoryToMonitor(String slug, String nameWithOwner)
147147
throw new RepositoryAlreadyMonitoredException(nameWithOwner);
148148
}
149149

150-
// Validate that repository exists in the database
151-
var repository = findRepository(nameWithOwner);
152-
if (repository.isEmpty()) {
153-
log.debug(
154-
"Skipped repository monitor addition: reason=repositoryNotFound, nameWithOwner={}",
155-
LoggingUtils.sanitizeForLog(nameWithOwner)
156-
);
157-
throw new EntityNotFoundException("Repository", nameWithOwner);
150+
// For GitLab PAT workspaces, the repo may not be synced yet — allow adding by name.
151+
// For other modes, validate that the repository exists in the database.
152+
if (!Workspace.GitProviderMode.GITLAB_PAT.equals(workspace.getGitProviderMode())) {
153+
var repository = findRepository(nameWithOwner);
154+
if (repository.isEmpty()) {
155+
log.debug(
156+
"Skipped repository monitor addition: reason=repositoryNotFound, nameWithOwner={}",
157+
LoggingUtils.sanitizeForLog(nameWithOwner)
158+
);
159+
throw new EntityNotFoundException("Repository", nameWithOwner);
160+
}
158161
}
159162

160163
log.info(

0 commit comments

Comments
 (0)