Fix: Traefik proxy startup issues - handle null versions and filter predefined networks

Fixes two critical issues preventing Traefik proxy startup:

1. TypeError when restarting proxy: Handle null return from get_traefik_versions()
   - Add null check before dispatching CheckTraefikVersionForServerJob
   - Log warning when version data is unavailable
   - Prevents: "Argument #2 must be of type array, null given"

2. Docker network error: Filter out predefined Docker networks
   - Add isDockerPredefinedNetwork() helper to centralize network filtering
   - Apply filtering in collectDockerNetworksByServer() before operations
   - Apply filtering in generateDefaultProxyConfiguration()
   - Prevents: "operation is not permitted on predefined default network"

Also: Move $cachedVersionsFile assignment after null check in Proxy.php

Tests: Added 7 new unit tests for network filtering function
All existing tests pass with no regressions

🤖 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-28 17:53:26 +01:00
parent b246cdffab
commit cb0f2301f5
4 changed files with 69 additions and 7 deletions

View File

@@ -153,3 +153,39 @@ it('compares branches for minor upgrades', function () {
expect($result)->toBeTrue();
});
it('identifies default as predefined network', function () {
expect(isDockerPredefinedNetwork('default'))->toBeTrue();
});
it('identifies host as predefined network', function () {
expect(isDockerPredefinedNetwork('host'))->toBeTrue();
});
it('identifies coolify as not predefined network', function () {
expect(isDockerPredefinedNetwork('coolify'))->toBeFalse();
});
it('identifies coolify-overlay as not predefined network', function () {
expect(isDockerPredefinedNetwork('coolify-overlay'))->toBeFalse();
});
it('identifies custom networks as not predefined', function () {
$customNetworks = ['my-network', 'app-network', 'custom-123'];
foreach ($customNetworks as $network) {
expect(isDockerPredefinedNetwork($network))->toBeFalse();
}
});
it('identifies bridge as not predefined (per codebase pattern)', function () {
// 'bridge' is technically a Docker predefined network, but existing codebase
// only filters 'default' and 'host', so we maintain consistency
expect(isDockerPredefinedNetwork('bridge'))->toBeFalse();
});
it('identifies none as not predefined (per codebase pattern)', function () {
// 'none' is technically a Docker predefined network, but existing codebase
// only filters 'default' and 'host', so we maintain consistency
expect(isDockerPredefinedNetwork('none'))->toBeFalse();
});