{"record":{"id":"bab542ab70354c57","repo":"docker/compose","slug":"cannot-render-project-into-yaml-w","errorCode":null,"errorMessage":"cannot render project into yaml: %w","messagePattern":"cannot render project into yaml: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/bridge/convert.go","lineNumber":64,"sourceCode":"\tOutput          string\n\tTemplates       string\n\tTransformations []string\n}\n\nfunc Convert(ctx context.Context, dockerCli command.Cli, project *types.Project, opts ConvertOptions) error {\n\tif len(opts.Transformations) == 0 {\n\t\topts.Transformations = []string{DefaultTransformerImage}\n\t}\n\t// Load image references, secrets and configs, also expose ports\n\tproject, err := LoadAdditionalResources(ctx, dockerCli, project)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// for user to rely on compose.yaml attribute names, not go struct ones, we marshall back into YAML\n\traw, err := project.MarshalYAML(types.WithSecretContent)\n\t// Marshall to YAML\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot render project into yaml: %w\", err)\n\t}\n\tvar model map[string]any\n\terr = yaml.Unmarshal(raw, &model)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot render project into yaml: %w\", err)\n\t}\n\n\tif opts.Output != \"\" {\n\t\t_ = os.RemoveAll(opts.Output)\n\t\terr := os.MkdirAll(opts.Output, 0o744)\n\t\tif err != nil && !os.IsExist(err) {\n\t\t\treturn fmt.Errorf(\"cannot create output folder: %w\", err)\n\t\t}\n\t}\n\t// Run Transformers images\n\treturn convert(ctx, dockerCli, model, opts)\n}\n","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/pkg/bridge/convert.go#L46-L82","documentation":"In the compose-to-Podman-bridge converter (bridge.Convert), the project is serialized back to YAML (project.MarshalYAML with types.WithSecretContent) so transformers can operate on compose-style attribute names. This error means that serialization itself failed. The %w wraps the underlying marshal error, which almost always indicates data in the in-memory project that cannot be represented in the compose YAML schema.","triggerScenarios":"Calling bridge.Convert with a programmatically built *types.Project containing values that do not survive marshal/unmarshal (custom types, invalid map keys, unsupported fields); a project mutated by LoadAdditionalResources into a state the YAML schema rejects.","commonSituations":"Using the bridge converter (docker compose-to-podman style flows) on a project with unusual or manually constructed fields; version mismatches between compose-go model structs and the YAML schema; injecting non-serializable content into service maps before conversion.","solutions":["Inspect the wrapped error (%w) to identify which field failed to marshal","Reproduce with docker compose config on the same file to see whether the CLI itself rejects the model","Upgrade docker/compose and compose-go to matching versions so model structs and YAML schema agree","Simplify the project (remove the suspicious service/field) and re-add pieces until the failing attribute is isolated"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := bridge.Convert(ctx, dockerCli, project, opts); err != nil {\n\tif strings.Contains(err.Error(), \"cannot render project into yaml\") {\n\t\t// inspect project for non-serializable fields; fall back to a file-loaded project\n\t\tlog.Printf(\"conversion input invalid: %v\", errors.Unwrap(err))\n\t}\n\treturn err\n}","preventionTips":["Prefer loading projects from compose files via the standard loader rather than building them by hand","Keep compose-go model structs and yaml library versions aligned with the compose release you call","Round-trip test: MarshalYAML then Unmarshal any programmatically built project before passing it to the bridge"],"tags":["bridge","yaml","serialization","convert"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}