Fix null handling for custom_port to prevent SSH connection failures

Previously, when custom_port was null (the common case), the code would
set the port to null, breaking SSH connections. This fix adds proper
null checks and defaults to port 22 when custom_port is not set.

Changes:
- Add null check before comparing custom_port to prevent null assignment
- Cast custom_port to int for type safety
- Default to port 22 when custom_port is null in fallback URL construction

Fixes the issue reported by CodeRabbit in PR review.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude Code 2025-11-02 20:07:33 +00:00
parent b6650a099d
commit 174a766ae6

View file

@ -3036,8 +3036,8 @@ function convertGitUrl(string $gitRepository, string $deploymentType, GithubApp|
switch ($source->getMorphClass()) {
case \App\Models\GithubApp::class:
case \App\Models\GitlabApp::class:
if ($source->custom_port !== 22) {
$providerInfo['port'] = $source->custom_port;
if ($source->custom_port !== null && (int) $source->custom_port !== 22) {
$providerInfo['port'] = (int) $source->custom_port;
}
break;
}
@ -3050,7 +3050,7 @@ function convertGitUrl(string $gitRepository, string $deploymentType, GithubApp|
case \App\Models\GithubApp::class:
case \App\Models\GitlabApp::class:
$providerInfo['host'] = Url::fromString($source->html_url)->getHost();
$providerInfo['port'] = $source->custom_port;
$providerInfo['port'] = $source->custom_port ?? 22;
$providerInfo['user'] = $source->custom_user;
break;
}