fix: convert Stringable to plain strings in applicationParser for strict comparisons and collection lookups

This fixes critical bugs where Stringable objects were used in strict comparisons and collection key lookups, causing service existence checks and domain lookups to fail.

**Changes:**
- Line 539: Added ->value() to $originalServiceName conversion
- Line 541: Added ->value() to $serviceName normalization
- Line 621: Removed redundant (string) cast now that $serviceName is a plain string

**Impact:**
- Service existence check now works correctly (line 606: $transformedServiceName === $serviceName)
- Domain lookup finds existing domains (line 615: $domains->get($serviceName))
- Prevents duplicate domain entries in docker_compose_domains collection

**Tests:**
- Added comprehensive unit test suite in ApplicationParserStringableTest.php
- 9 test cases covering type verification, strict comparisons, collection operations, and edge cases
- All tests pass (24 tests, 153 assertions across related parser tests)

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2025-11-24 09:22:27 +01:00
parent 64cbda0140
commit 75381af742
2 changed files with 185 additions and 3 deletions
+3 -3
View File
@@ -536,9 +536,9 @@ function applicationParser(Application $resource, int $pull_request_id = 0, ?int
}
}
$originalServiceName = str($serviceName)->replace('_', '-');
$originalServiceName = str($serviceName)->replace('_', '-')->value();
// Always normalize service names to match docker_compose_domains lookup
$serviceName = str($serviceName)->replace('-', '_')->replace('.', '_');
$serviceName = str($serviceName)->replace('-', '_')->replace('.', '_')->value();
// Generate BOTH FQDN & URL
$fqdn = generateFqdn(server: $server, random: "$originalServiceName-$uuid", parserVersion: $resource->compose_parsing_version);
@@ -618,7 +618,7 @@ function applicationParser(Application $resource, int $pull_request_id = 0, ?int
$domainValue = $port ? $urlWithPort : $url;
if (is_null($domainExists)) {
$domains->put((string) $serviceName, [
$domains->put($serviceName, [
'domain' => $domainValue,
]);
$resource->docker_compose_domains = $domains->toJson();