{"record":{"id":"c8d86c5326d5b563","repo":"docker/cli","slug":"invalid-type-t-for-ulimits","errorCode":null,"errorMessage":"invalid type %T for ulimits","messagePattern":"invalid type %T for ulimits","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/compose/loader/loader.go","lineNumber":535,"sourceCode":"\t\t\tlogrus.Warn(\"cannot expand '~', because the environment lacks HOME\")\n\t\t\treturn srcPath\n\t\t}\n\t\treturn strings.Replace(srcPath, \"~\", home, 1)\n\t}\n\treturn srcPath\n}\n\nfunc transformUlimits(data any) (any, error) {\n\tswitch value := data.(type) {\n\tcase int:\n\t\treturn types.UlimitsConfig{Single: value}, nil\n\tcase map[string]any:\n\t\tulimit := types.UlimitsConfig{}\n\t\tulimit.Soft = value[\"soft\"].(int)\n\t\tulimit.Hard = value[\"hard\"].(int)\n\t\treturn ulimit, nil\n\tdefault:\n\t\treturn data, fmt.Errorf(\"invalid type %T for ulimits\", value)\n\t}\n}\n\n// LoadNetworks produces a NetworkConfig map from a compose file Dict\n// the source Dict is not validated if directly used. Use Load() to enable validation\nfunc LoadNetworks(source map[string]any, version string) (map[string]types.NetworkConfig, error) {\n\tnetworks := make(map[string]types.NetworkConfig)\n\terr := Transform(source, &networks)\n\tif err != nil {\n\t\treturn networks, err\n\t}\n\tfor name, nw := range networks {\n\t\tif !nw.External.External {\n\t\t\tcontinue\n\t\t}\n\t\tswitch {\n\t\tcase nw.External.Name != \"\":\n\t\t\tif nw.Name != \"\" {","sourceCodeStart":517,"sourceCodeEnd":553,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/compose/loader/loader.go#L517-L553","documentation":"Thrown by transformUlimits during schema transformation of a service's `ulimits` mapping. Each ulimit value must be either a bare integer (shorthand where soft==hard) or a map with `soft` and `hard` integer keys. Any other YAML scalar/sequence (quoted string, list, bool, null) hits the default branch and is rejected.","triggerScenarios":"A service defines `ulimits:` where an entry value is not int or map — e.g. `ulimits: nproc: \"65535\"` (quoted), `nproc: [65535]` (list), or `nproc: ~`. The transformer is invoked by Transform() for every key under service.ulimits.","commonSituations":"Quoting the number in YAML, copying an example whose indentation turns the map into a string, or tooling that emits ulimits as strings.","solutions":["Use a bare integer: `ulimits: { nproc: 65535 }`.","Or use the explicit map form: `ulimits: { nproc: { soft: 65535, hard: 65535 } }`.","Remove any quotes around the numeric value."],"exampleFix":"# before\nservices:\n  web:\n    ulimits:\n      nproc: \"65535\"\n# after\nservices:\n  web:\n    ulimits:\n      nproc: 65535","handlingStrategy":"validation","validationCode":"// validate service.ulimits before Transform()\nfunc validateUlimits(svc map[string]any) error {\n    u, ok := svc[\"ulimits\"]\n    if !ok {\n        return nil\n    }\n    m, ok := u.(map[string]any)\n    if !ok {\n        return fmt.Errorf(\"ulimits must be a mapping\")\n    }\n    for name, v := range m {\n        switch t := v.(type) {\n        case int:\n            // ok\n        case map[string]any:\n            if _, ok := t[\"soft\"].(int); !ok {\n                return fmt.Errorf(\"ulimits.%s.soft must be int\", name)\n            }\n            if _, ok := t[\"hard\"].(int); !ok {\n                return fmt.Errorf(\"ulimits.%s.hard must be int\", name)\n            }\n        default:\n            return fmt.Errorf(\"ulimits.%s: invalid type %T\", name, v)\n        }\n    }\n    return nil\n}","typeGuard":"func isUlimitValue(v any) bool {\n    switch v.(type) {\n    case int:\n        return true\n    case map[string]any:\n        _, softOk := v.(map[string]any)[\"soft\"].(int)\n        _, hardOk := v.(map[string]any)[\"hard\"].(int)\n        return softOk && hardOk\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Run `docker compose config` to validate a file before deploying.","Lint compose files in CI (e.g. docker compose config --quiet).","Never quote numeric ulimit values."],"tags":["compose","ulimits","type-mismatch","service"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}