{"record":{"id":"0b3b4a277d9af28d","repo":"containerd/containerd","slug":"failed-to-marshal-toml-blob-for-runtime-q-w","errorCode":null,"errorMessage":"failed to marshal TOML blob for runtime %q: %w","messagePattern":"failed to marshal TOML blob for runtime %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cri/config/config.go","lineNumber":792,"sourceCode":"\tnamespaceOptions := securityContext.GetNamespaceOptions()\n\tif namespaceOptions.GetNetwork() == runtime.NamespaceMode_NODE ||\n\t\tnamespaceOptions.GetPid() == runtime.NamespaceMode_NODE ||\n\t\tnamespaceOptions.GetIpc() == runtime.NamespaceMode_NODE {\n\t\treturn true\n\t}\n\n\treturn false\n}\n\n// GenerateRuntimeOptions generates runtime options from cri plugin config.\nfunc GenerateRuntimeOptions(r Runtime) (any, error) {\n\tif r.Options == nil {\n\t\treturn nil, nil\n\t}\n\n\tb, err := toml.Marshal(r.Options)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to marshal TOML blob for runtime %q: %w\", r.Type, err)\n\t}\n\n\toptions := getRuntimeOptionsType(r.Type)\n\tif err := toml.Unmarshal(b, options); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// For generic configuration, if no config path specified (preserving old behavior), pass\n\t// the whole TOML configuration section to the runtime.\n\tif runtimeOpts, ok := options.(*runtimeoptions.Options); ok && runtimeOpts.ConfigPath == \"\" {\n\t\truntimeOpts.ConfigBody = b\n\t}\n\n\treturn options, nil\n}\n\n// getRuntimeOptionsType gets empty runtime options by the runtime type name.\nfunc getRuntimeOptionsType(t string) any {","sourceCodeStart":774,"sourceCodeEnd":810,"githubUrl":"https://github.com/containerd/containerd/blob/4246446a2bf7d03837b0244118d858799393bd80/internal/cri/config/config.go#L774-L810","documentation":"When decoding runtime options, the config marshals the raw TOML options table (r.Options) back to bytes with toml.Marshal, keyed by r.Type in the error message. If marshaling the in-memory options blob fails, this wrapped error is returned. This happens before unmarshaling into the concrete runtime-options type, so it indicates the stored options structure itself could not be re-encoded as TOML.","triggerScenarios":"Call getRuntimeOptionsBlock for a runtime whose Options map contains values that the TOML marshaller cannot encode (unsupported nested types produced via config decoding or TOML edge cases), during containerd startup when loading runtime configs.","commonSituations":"Unusual/exotic values in the `[containerd.runtimes.X.options]` table of config.toml, plugin version changes altering how options are represented, or programmatically-built Config objects with non-encodable option values.","solutions":["Inspect and simplify the options table for the runtime named in the error in config.toml; use only scalar/string/bool/nested-table values.","Regenerate the runtime options using the documented schema for the runtime_type (e.g. SystemdCgroup for runc).","Upgrade/align containerd and the runtime so option marshaling matches expected types.","If constructing Config in Go, ensure Options is a map[string]interface{} of TOML-encodable values."],"exampleFix":"// before (config.toml)\n[plugins.\"io.containerd.grpc.v1.cri\".containerd.runtimes.runc.options]\n  SystemdCgroup = \"true\"  # odd type from template\n\n// after (config.toml)\n[plugins.\"io.containerd.grpc.v1.cri\".containerd.runtimes.runc.options]\n  SystemdCgroup = true","handlingStrategy":"validation","validationCode":"_, err := toml.Marshal(runtime.Options)\nif err != nil {\n    return fmt.Errorf(\"runtime %q options not TOML-encodable: %w\", runtime.Type, err)\n}","typeGuard":"func tomlEncodable(v map[string]interface{}) bool {\n    _, err := toml.Marshal(v)\n    return err == nil\n}","tryCatchPattern":"b, err := toml.Marshal(r.Options)\nif err != nil {\n    return nil, fmt.Errorf(\"runtime %q: %w\", r.Type, err)\n}","preventionTips":["Keep runtime options limited to documented scalar fields (booleans, strings, ints).","Test config.toml parsing/marshaling in CI with the same containerd version as production.","Avoid hand-rolled Config construction with arbitrary interface{} option values."],"tags":["containerd","cri","toml","serialization"],"backgroundTag":"toml-marshal-failed","analyzedSha":"4246446a2bf7d03837b0244118d858799393bd80","analyzedAt":"2026-09-02T00:14:43.053Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}