mirror of
https://github.com/coollabsio/coolify.git
synced 2026-03-11 08:55:47 +00:00
This commit adds comprehensive validation improvements and DRY principles for handling Coolify's custom Docker Compose extensions. ## Changes ### 1. Created Reusable stripCoolifyCustomFields() Function - Added shared helper in bootstrap/helpers/docker.php - Removes all Coolify custom fields (exclude_from_hc, content, isDirectory, is_directory) - Handles both long syntax (arrays) and short syntax (strings) for volumes - Well-documented with comprehensive docblock - Follows DRY principle for consistent field stripping ### 2. Fixed Docker Compose Modal Validation - Updated validateComposeFile() to use stripCoolifyCustomFields() - Now removes ALL custom fields before Docker validation (previously only removed content) - Fixes validation errors when using templates with custom fields (e.g., traccar.yaml) - Users can now validate compose files with Coolify extensions in UI ### 3. Enhanced YAML Validation in CalculatesExcludedStatus - Added proper exception handling with ParseException vs generic Exception - Added structure validation (checks if parsed result and services are arrays) - Comprehensive logging with context (error message, line number, snippet) - Maintains safe fallback behavior (returns empty collection on error) ### 4. Added Integer Validation to ContainerStatusAggregator - Validates maxRestartCount parameter in both aggregateFromStrings() and aggregateFromContainers() - Corrects negative values to 0 with warning log - Logs warnings for suspiciously high values (> 1000) - Prevents logic errors in crash loop detection ### 5. Comprehensive Unit Tests - tests/Unit/StripCoolifyCustomFieldsTest.php (NEW) - 9 tests, 43 assertions - tests/Unit/ContainerStatusAggregatorTest.php - Added 6 tests for integer validation - tests/Unit/ExcludeFromHealthCheckTest.php - Added 4 tests for YAML validation - All tests passing with proper Log facade mocking ### 6. Documentation - Added comprehensive Docker Compose extensions documentation to .ai/core/deployment-architecture.md - Documents all custom fields: exclude_from_hc, content, isDirectory/is_directory - Includes examples, use cases, implementation details, and test references - Updated .ai/README.md with navigation links to new documentation ## Benefits - Better UX: Users can validate compose files with custom fields - Better Debugging: Comprehensive logging for errors - Better Code Quality: DRY principle with reusable validation - Better Reliability: Prevents logic errors from invalid parameters - Better Maintainability: Easy to add new custom fields in future 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| Actions/User | ||
| Livewire | ||
| Notifications/Channels | ||
| Policies | ||
| Rules | ||
| AllExcludedContainersConsistencyTest.php | ||
| ApplicationComposeEditorLoadTest.php | ||
| ApplicationConfigurationChangeTest.php | ||
| ApplicationDeploymentCustomBuildCommandTest.php | ||
| ApplicationDeploymentEmptyEnvTest.php | ||
| ApplicationDeploymentErrorLoggingTest.php | ||
| ApplicationGitSecurityTest.php | ||
| ApplicationHealthcheckRemovalTest.php | ||
| ApplicationNetworkAliasesSyncTest.php | ||
| ApplicationPortDetectionTest.php | ||
| ApplicationSettingStaticCastTest.php | ||
| ApplicationWatchPathsTest.php | ||
| BashEnvEscapingTest.php | ||
| CheckTraefikVersionForServerJobTest.php | ||
| CheckTraefikVersionJobTest.php | ||
| CloudInitScriptValidationTest.php | ||
| ContainerHealthStatusTest.php | ||
| ContainerStatusAggregatorTest.php | ||
| DatalistComponentTest.php | ||
| DeploymentExceptionTest.php | ||
| DockerComposeEmptyStringPreservationTest.php | ||
| DockerComposeEmptyTopLevelSectionsTest.php | ||
| DockerComposeLabelParsingTest.php | ||
| DockerComposeRawContentRemovalTest.php | ||
| DockerComposeRawSeparationTest.php | ||
| DockerfileArgInsertionTest.php | ||
| DockerImageAutoParseTest.php | ||
| DockerImageParserTest.php | ||
| ExcludeFromHealthCheckTest.php | ||
| GetContainersStatusServiceAggregationTest.php | ||
| GitLsRemoteParsingTest.php | ||
| GlobalSearchNewImageQuickActionTest.php | ||
| HetznerDeletionFailedNotificationTest.php | ||
| HetznerSshKeysTest.php | ||
| NotifyOutdatedTraefikServersJobTest.php | ||
| ParseCommandsByLineForSudoTest.php | ||
| ParseDockerVolumeStringTest.php | ||
| PreSaveValidationTest.php | ||
| PrivateKeyStorageTest.php | ||
| ProxyCustomCommandsTest.php | ||
| ProxyHelperTest.php | ||
| RestartCountTrackingTest.php | ||
| ScheduledJobManagerLockTest.php | ||
| ScheduledJobsRetryConfigTest.php | ||
| ScheduledTaskJobTimeoutTest.php | ||
| ServerQueryScopeTest.php | ||
| ServerStatusAccessorTest.php | ||
| ServiceConfigurationRefreshTest.php | ||
| ServiceExcludedStatusTest.php | ||
| ServiceNameSecurityTest.php | ||
| ServiceParserImageUpdateTest.php | ||
| ServiceParserPortDetectionLogicTest.php | ||
| ServicePortSpecificVariablesTest.php | ||
| ServiceRequiredPortTest.php | ||
| SshRetryMechanismTest.php | ||
| StartProxyTest.php | ||
| StartupExecutionCleanupTest.php | ||
| StopProxyTest.php | ||
| StripCoolifyCustomFieldsTest.php | ||
| TimescaleDbDetectionTest.php | ||
| ValidateShellSafePathTest.php | ||
| ValidGitRepositoryUrlTest.php | ||
| ValidHostnameTest.php | ||
| VolumeArrayFormatSecurityTest.php | ||
| VolumeSecurityTest.php | ||
| WindowsPathVolumeTest.php | ||