{"record":{"id":"a62a606e7c86a61a","repo":"kubernetes/kubernetes","slug":"unable-to-locate-encoder-q-is-not-a-supported","errorCode":null,"errorMessage":"unable to locate encoder -- %q is not a supported media type","messagePattern":"unable to locate encoder -- %q is not a supported media type","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kube-proxy/app/options.go","lineNumber":415,"sourceCode":"\t// run the proxy in goroutine\n\tgo func() {\n\t\terr := o.proxyServer.Run(ctx)\n\t\to.errCh <- err\n\t}()\n\n\tfor {\n\t\terr := <-o.errCh\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n}\n\nfunc (o *Options) writeConfigFile() (err error) {\n\tconst mediaType = runtime.ContentTypeYAML\n\tinfo, ok := runtime.SerializerInfoForMediaType(proxyconfigscheme.Codecs.SupportedMediaTypes(), mediaType)\n\tif !ok {\n\t\treturn fmt.Errorf(\"unable to locate encoder -- %q is not a supported media type\", mediaType)\n\t}\n\n\tencoder := proxyconfigscheme.Codecs.EncoderForVersion(info.Serializer, v1alpha1.SchemeGroupVersion)\n\n\tconfigFile, err := os.Create(o.WriteConfigTo)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdefer func() {\n\t\tferr := configFile.Close()\n\t\tif ferr != nil && err == nil {\n\t\t\terr = ferr\n\t\t}\n\t}()\n\n\tif err = encoder.Encode(o.config, configFile); err != nil {\n\t\treturn err","sourceCodeStart":397,"sourceCodeEnd":433,"githubUrl":"https://github.com/kubernetes/kubernetes/blob/b882c60b4023bdf09264c2d5d30a2cadebc240fb/cmd/kube-proxy/app/options.go#L397-L433","documentation":"When writing the default config (--write-config-to), kube-proxy asks the codec factory for a serializer matching runtime.ContentTypeYAML. If no YAML serializer is registered in proxyconfigscheme.Codecs, SerializerInfoForMediaType returns !ok and the error 'unable to locate encoder -- \"application/yaml\" is not a supported media type' is returned (options.go:415).","triggerScenarios":"A custom or stripped kube-proxy build where the YAML serializer was not added to the proxy config scheme, or scheme registration order omitted the YAML codec. The media type is hardcoded, so the value can never be the user's fault.","commonSituations":"A fork that rebuilt proxyconfigscheme.Scheme without YAML support; a binary built with an incompatible apimachinery codec factory; running --write-config-to against a malformed scheme init.","solutions":["Use a stock kube-proxy build where YAML is registered in the proxy config scheme.","Ensure kubeproxyconfig/v1alpha1 AddToScheme and the YAML codec are both wired before Codecs is used.","If you only need JSON output and the build supports it, patch writeConfigFile to request JSON — but prefer fixing scheme registration.","Rebuild from an unmodified source tree."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify a YAML serializer exists before calling --write-config-to.\nfunc yamlEncoderAvailable() error {\n    for _, si := range proxyconfigscheme.Codecs.SupportedMediaTypes() {\n        if si.MediaType == runtime.ContentTypeYAML {\n            return nil\n        }\n    }\n    return fmt.Errorf(\"application/yaml is not a supported media type\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use stock kube-proxy builds where YAML is registered in the proxy config scheme.","Do not strip codecs when forking the scheme.","Keep config/v1alpha1 scheme registration intact."],"tags":["kubernetes","kube-proxy","serializer","yaml","scheme"],"analyzedSha":"b882c60b4023bdf09264c2d5d30a2cadebc240fb","analyzedAt":"2026-08-07T04:07:48.144Z","schemaVersion":2},"datasetVersion":"2026-08-07T07:17:06.508Z"}