Skip to content

fix(parsing): support map form of depends_on with condition syntax#75

Open
24601 wants to merge 1 commit intoMcrich23:mainfrom
24601:fix/depends-on-map-form
Open

fix(parsing): support map form of depends_on with condition syntax#75
24601 wants to merge 1 commit intoMcrich23:mainfrom
24601:fix/depends-on-map-form

Conversation

@24601
Copy link
Copy Markdown

@24601 24601 commented Apr 22, 2026

Problem

container-compose throws a typeMismatch error on any compose file that uses the map form of depends_on:

depends_on:
  db:
    condition: service_healthy

This is valid Docker Compose spec (v2+) and is common in real-world stacks (Windmill, Keycloak, Traefik setups, etc). Only the list form worked:

depends_on:
  - db

Fix

In Service.swift, after failing to decode as String or [String], attempt to decode as [String: [String: String]] and extract the map keys as the dependency list. Conditions are dropped since Apple Container has no equivalent orchestration-layer concept.

} else if let dependsOnMap = try? container.decodeIfPresent([String: [String: String]].self, forKey: .depends_on) {
    // Map form: depends_on: { db: { condition: service_healthy } }
    // Preserve dependency order; conditions are not applicable to Apple Container.
    depends_on = dependsOnMap.keys.sorted()
}

Tests

Added parseComposeWithDependenciesMapForm covering:

  • Two dependencies with different condition values (service_healthy, service_started)
  • Both service names extracted correctly
  • Count assertion

Both new and existing depends_on tests pass.

Verified against

Windmill CE docker-compose.yml — previously failed at parse, now reaches image pull stage.

Docker Compose allows depends_on to be expressed as either a list:

  depends_on:
    - db

or a map with condition metadata:

  depends_on:
    db:
      condition: service_healthy

container-compose only handled the list (and single-string) forms,
throwing a typeMismatch error on the map form. This caused failures
on any real-world compose file that uses health-check gating.

Fix: after failing to decode as String or [String], attempt to decode
as [String: [String: String]] and extract the keys as the dependency
list. Conditions are silently dropped since Apple Container has no
equivalent concept at the orchestration layer.

Adds a parsing test covering the two-service map form with mixed
condition values (service_healthy, service_started).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant