{"record":{"id":"cc33e567ce3ee1ca","repo":"containerd/containerd","slug":"failed-to-apply-config-opt-w-cc33e5","errorCode":null,"errorMessage":"failed to apply config opt: %w","messagePattern":"failed to apply config opt: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/diff/erofs/differ.go","lineNumber":172,"sourceCode":"\t\treturn emptyDesc, fmt.Errorf(\"unsupported media type: %s\", desc.MediaType)\n\t}\n\n\tswitch {\n\tcase fastcopy:\n\t\tmode = \"fastcopy\"\n\tcase native:\n\t\tmode = \"native\"\n\tcase s.enableTarIndex:\n\t\tmode = \"tar-index\"\n\tdefault:\n\t\tmode = \"convert\"\n\t}\n\tspan.SetAttributes(tracing.Attribute(\"erofs.apply.mode\", mode))\n\n\tvar config diff.ApplyConfig\n\tfor _, o := range opts {\n\t\tif err := o(ctx, desc, &config); err != nil {\n\t\t\treturn emptyDesc, fmt.Errorf(\"failed to apply config opt: %w\", err)\n\t\t}\n\t}\n\n\tlayer, err := erofsutils.MountsToLayer(mounts)\n\tif err != nil {\n\t\treturn emptyDesc, err\n\t}\n\n\tra, err := s.store.ReaderAt(ctx, desc)\n\tif err != nil {\n\t\treturn emptyDesc, fmt.Errorf(\"failed to get reader from content store: %w\", err)\n\t}\n\tdefer ra.Close()\n\n\tlayerBlobPath := path.Join(layer, \"layer.erofs\")\n\t// Allow copy file range when there is an uncompressed native EROFS layer\n\tif fastcopy {\n\t\tf, err := os.Create(layerBlobPath)","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/containerd/containerd/blob/4246446a2bf7d03837b0244118d858799393bd80/plugins/diff/erofs/differ.go#L154-L190","documentation":"Apply first runs each provided ApplyOpt (diff.ApplyConfig option) against a fresh diff.ApplyConfig. If any option function returns an error, it is wrapped as \"failed to apply config opt\" and Apply aborts before doing any layer work. The wrapped error comes from the option itself (e.g. an invalid window/block-size config, filesystem option rejection, or a context cancellation inside the opt).","triggerScenarios":"Passing a diff.WithApplyOpt/ApplyOpt to Apply (directly or via CRI/pull configuration, e.g. erofs-specific opts like chunk/block size, compress hints, or remap-ids options) whose function validates inputs and fails; ctx already cancelled; passing an opt meant for a different differ.","commonSituations":"Misconfigured apply options in the CRI/pull config (unsupported values for the mounted EROFS filesystem); applying opts that require kernel/filesystem features the host lacks; a bug or version mismatch between the caller constructing opts and the plugin version interpreting them.","solutions":["Read the wrapped cause in the error (%w) — it names the failing option; correct that option's value or remove it.","Log/inspect the opts being passed to Apply and confirm each is valid for this differ version.","Check host kernel support for the EROFS features requested by the opts (e.g. zstd decompression, chunk dedup) — upgrade the kernel or drop those opts.","Retry after fixing; if ctx is cancelled, re-create the context with a proper timeout."],"exampleFix":"// before\ndiffer.Apply(ctx, sn, mounts, desc, diff.WithWindow(0)) // invalid value rejected by opt\n// after\ndiffer.Apply(ctx, sn, mounts, desc, diff.WithWindow(32<<20)) // valid config value","handlingStrategy":"try-catch","validationCode":"var cfg diff.ApplyConfig\nfor _, o := range opts {\n    if err := o(ctx, desc, &cfg); err != nil {\n        return fmt.Errorf(\"invalid apply opt for %s: %w\", desc.MediaType, err)\n    }\n}\n// opts validated; safe to call Apply with the same opts","typeGuard":"func optsValid(ctx context.Context, desc ocispec.Descriptor, opts ...diff.ApplyOpt) bool {\n    var cfg diff.ApplyConfig\n    for _, o := range opts {\n        if err := o(ctx, desc, &cfg); err != nil { return false }\n    }\n    return true\n}","tryCatchPattern":"desc, err := differ.Apply(ctx, sn, mounts, layerDesc, opts...)\nif err != nil && strings.Contains(err.Error(), \"failed to apply config opt\") {\n    // drop custom opts and retry with defaults\n    desc, err = differ.Apply(ctx, sn, mounts, layerDesc)\n}","preventionTips":["Dry-run ApplyOpts against a scratch ApplyConfig before calling Apply.","Keep apply-option configuration (CRI config) in sync with the plugin version's supported options.","Verify host kernel/filesystem features required by the opts (zstd, chunk dedup, fs verity).","Ensure contexts passed to Apply are not already cancelled or expired."],"tags":["erofs","apply-config","options","containerd"],"backgroundTag":"apply-option-rejected","analyzedSha":"4246446a2bf7d03837b0244118d858799393bd80","analyzedAt":"2026-09-02T00:14:43.053Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}