Skip to content

Got error "Expected to decode Int but found Scalar instead." if i use an env var in an assignment to "replicas" #95

Closed

Description

@ar4hc

Hi,

stumbled upon this:

Error: DecodingError.typeMismatch: expected value of type Int. Path: services.<oo.deploy.replicas. Debug description: Expected to decode Int but found Scalar instead.

when running

container-compose up --env-file .env -f compose.yml

Relevant parts of the Docker compose yaml looks like this

    deploy:
      mode: replicated
      replicas: ${CORES}

and in .env is

CORES=1

(not CORES="1")

I assume the Decoder looks at this before the variable is resolved...?
So it seed the string "${CORES}" instead of the "1", as the value, from the .env file?

Can i work around this somehow? (other than hard coding the values in the compose file...)

Activity

  1. Mcrich23 commented on May 29, 2026

    @Mcrich23
    Owner

    This is a very confusing parsing issue since it should be able to parse 1 as an Integer. I will look into this in the coming weeks. For now, I am curious if replacing ${CORES}in the compose file fixes the issue.

  2. danekszy commented on Jul 7, 2026

    @danekszy

    Similarly, CC also seems to assume volumes list can only consist of string items and not volume objects (which are valid in docker-compose files).
    Example:

    - type: bind
      source: /path/abc
      target: /path/def
      read_only: true
    

    ...producing type error...

    Error: typeMismatch(Yams.Node.Scalar, Swift.DecodingError.Context(codingPath: [
    CodingKeys(stringValue: "services", intValue: nil),
    _DictionaryCodingKey(stringValue: "my-service", intValue: nil),
    CodingKeys(stringValue: "volumes", intValue: nil),
    _YAMLCodingKey(stringValue: "Index 1", intValue: 1)],
    debugDescription: "Expected to decode Scalar but found Mapping instead.", underlyingError: nil))
    

    Not sure whether that info is worthy of creating another issue or not... Let me know if you'd like me to create one for that... ;)

  3. mvanhorn commented on Jul 10, 2026

    @mvanhorn
    Contributor

    Implemented in #129.

  4. added a commit that references this issue on Jul 22, 2026
    3072f7a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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