ProjectService infers repo type from gitUrl presence instead of explicit repoType field (SZ-118)
rk@tigase.net opened 2 days ago

Problem

ProjectServiceImpl.createProject() determines whether a repo is external or Sztabina-hosted by checking if gitUrl is non-blank:

final boolean isExternalRepo = gitUrl != null && !gitUrl.isBlank();

This is a side-effect-based inference that ignores the explicit repoType field on ProjectCreateDto. As a result, passing repoType: LOCAL with a gitUrl still triggers the external repo validation path, throwing:

"Username is required for external repositories"

This makes the API contract ambiguous and fragile — callers cannot express intent explicitly.

Expected Behavior

Repo type should be determined by the explicit repoType field:

  • repoType: EXTERNAL + gitUrl + gitUsername + gitPassword → external repo, validate all three
  • repoType: LOCAL → Sztabina-hosted, ignore any provided gitUrl/credentials, create repo internally

Current Behavior

Repo type is inferred from gitUrl presence alone. repoType field is ignored in the service layer entirely (ProjectCreateDto.effectiveRepoType() is never called by ProjectController.createProject()).

  • rk@tigase.net commented 2 days ago

    Worklog

    StepTaskEst
    1Add repoType param to ProjectService interface and ProjectServiceImpl30m
    2Replace gitUrl inference with explicit repoType check in service30m
    3Update ProjectController to pass dto.effectiveRepoType()15m
    4Test: create LOCAL project without gitUrl, create EXTERNAL project with credentials30m
  • rk@tigase.net commented 2 days ago

    Root Cause

    ProjectController.createProject() does not pass repoType to the service:

    final Project saved = projectService.createProject(
        dto.name(),
        dto.description(),
        dto.gitUrl(),
        dto.gitUsername(),
        dto.gitPassword(),
        dto.defaultBranchName(),
        owner,
        dto.effectiveVisibility()   // repoType is missing here
    );
    

    Fix

    1. Add repoType parameter to ProjectService.createProject() signature
    2. In ProjectServiceImpl, replace gitUrl-based inference with explicit repoType check:
    final boolean isExternalRepo = repoType == RepoType.EXTERNAL;
    
    1. Update ProjectController to pass dto.effectiveRepoType() to the service

    Notes

    • ProjectCreateDto.effectiveRepoType() already exists and defaults to EXTERNAL — just not wired through
    • Workaround for now: omit gitUrl when creating LOCAL projects — service falls into Sztabina path correctly
  • rk@tigase.net commented 2 days ago
    rksuma@Ramakrishnans-MacBook-Pro sztab % git checkout wolnosc
    git checkout -b bugfix/SZ-77-repoType-inference
    Switched to branch 'wolnosc'
    Your branch is up to date with 'origin/wolnosc'.
    Switched to a new branch 'bugfix/SZ-77-repoType-inference'
    rksuma@Ramakrishnans-MacBook-Pro sztab % git pull origin
    You asked to pull from the remote 'origin', but did not specify
    a branch. Because this is not the default configured remote
    for your current branch, you must specify a branch on the command line.
    rksuma@Ramakrishnans-MacBook-Pro sztab % git pull origin
    rksuma@Ramakrishnans-MacBook-Pro sztab % 
    
    
  • rk@tigase.net changed state to 'In Progress' 2 days ago
    Previous Value Current Value
    Open
    In Progress
  • rk@tigase.net commented 2 days ago

    Issue resolved, pushed to wolsonsc for 1.10.0 release.

  • rk@tigase.net changed state to 'Closed' 2 days ago
    Previous Value Current Value
    In Progress
    Closed
issue 1 of 1
Type
Bug
Priority
Normal
Assignee
Version
1.10.0
Sprints
n/a
Customer
n/a
Issue Votes (0)
Watchers (3)
Reference
SZ-118
Please wait...
Page is in error, reload to recover