Skip to content

"app env sync" fails with "cannot unmarshal array" on bulk update #49

@pfleigo

Description

@pfleigo

I am encountering a crash when running coolify app env sync against my Coolify instance. The command fails specifically during the bulk update phase with a JSON unmarshalling error, suggesting a mismatch between the expected API response (Object) and the actual response (Array).

Steps to Reproduce:

Have an application in Coolify with existing environment variables.
Create a local .env file that contains values for those existing variables (triggering the "update" logic).
Run the sync command:

coolify app env sync <app_uuid> --file .env

Expected Behavior:
The CLI should successfully update the existing environment variables.

Actual Behavior:
The CLI fails with the following error:

Updating X existing variables...
  ✗ Bulk update failed: failed to bulk update environment variables for application XXX: failed to unmarshal response: json: cannot unmarshal array into Go value of type service.BulkUpdateEnvsResponse

Looking at the source code in cmd/env/sync.go:

// ...
_, err := appSvc.BulkUpdateEnvs(ctx, uuid, bulkReq)
// ...

It seems BulkUpdateEnvs expects a service.BulkUpdateEnvsResponse struct (likely a JSON Object), but the API is returning a JSON Array [], causing the unmarshal error.

Environment:

Coolify CLI Version: latest (1.4.0)
Coolify Instance Version: v4.0.0-beta.456
OS: Alpine Linux (GitLab CI runner) / macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions