Skip to main content

Source Discovery & Connection Testing

Overview

When configuring a source, users can click "Test Connection" to validate credentials and auto-discover available projects/repositories, instead of entering project IDs manually.

How it works

  1. The frontend sends a POST /discover-projects request with source credentials.
  2. The backend dispatches to the provider-specific service (GitLab, GitHub, Bitbucket, FTP).
  3. For Git providers, the response includes the authenticated username and a list of accessible projects.
  4. An autocomplete dropdown lets the user select a project.
  5. For FTP, the test creates a temporary .bcyip_test directory, writes a file, then deletes it — verifying full Read/Write/Delete permissions.
  6. Connection errors display the exact failing URL in a styled code block to help debug 401/403/404.

Auto-discovered username (GitHub/GitLab)

  • The tokenName field is hidden for GitHub/GitLab; the username is auto-retrieved from /user on "Test Connection".
  • Displayed as "Connected as {username}"; persisted as username:token_value for clone auth.
  • Bitbucket and FTP keep manual fields (email / username).

GitLab project name persistence

  • path_with_namespace is stored as label in the project config when a GitLab project is selected.
  • Used in the summary page, init report, and webhook context — no extra API call needed.

Key files

  • src/app.controller.tsPOST /discover-projects endpoint
  • src/protocol/source/source.service.ts — Unified discovery dispatch + error URL enrichment
  • src/protocol/capacities/ftp-capacity/ftp-capacity.service.ts — FTP write permission test
  • ui/src/pages/workflows/stepForms/StepInitForm.tsx — Test Connection UI + auto-discover
  • ui/src/utils/format.tsProjectFormatter.unkey includes label

Technical decisions

  • DiscoverSourceParams provides a uniform interface across all providers.
  • FTP test uses absolute paths to avoid CWD issues on various server configurations.
  • ConfiguratorService / StateInterceptor fixed to prevent premature "Ready" state when only partial config is saved.