{"record":{"id":"2940e461a9dc66c7","repo":"symfony/http-kernel","slug":"unsupported-format-s","errorCode":null,"errorMessage":"Unsupported format: \"%s\".","messagePattern":"Unsupported format: \"(.+?)\"\\.","errorType":"http","errorClass":"UnsupportedMediaTypeHttpException","httpStatus":415,"severity":"error","filePath":"Controller/ArgumentResolver/RequestPayloadValueResolver.php","lineNumber":286,"sourceCode":"            $argument->isVariadic() => ($attribute->type ?? $argument->getType()).'[]',\n            'array' === $argument->getType() && null !== $attribute->type => $attribute->type.'[]',\n            default => $argument->getType(),\n        };\n\n        if (\\is_array($data)) {\n            $data = $this->mergeParamsAndFiles($data, $request->files->all());\n\n            return $this->serializer->denormalize($data, $type, self::hasNonStringScalar($data) ? $format : 'csv', $attribute->serializationContext + self::CONTEXT_DENORMALIZE + ('form' === $format ? ['filter_bool' => true] : []));\n        }\n\n        if ('form' === $format) {\n            throw new BadRequestHttpException('Request payload contains invalid \"form\" data.');\n        }\n\n        try {\n            return $this->serializer->deserialize($data, $type, $format, self::CONTEXT_DESERIALIZE + $attribute->serializationContext);\n        } catch (UnsupportedFormatException $e) {\n            throw new UnsupportedMediaTypeHttpException(\\sprintf('Unsupported format: \"%s\".', $format), $e);\n        } catch (NotEncodableValueException $e) {\n            throw new BadRequestHttpException(\\sprintf('Request payload contains invalid \"%s\" data.', $format), $e);\n        } catch (UnexpectedPropertyException $e) {\n            throw new BadRequestHttpException(\\sprintf('Request payload contains invalid \"%s\" property.', $e->property), $e);\n        }\n    }\n\n    private function mapUploadedFile(Request $request, ArgumentMetadata $argument, MapUploadedFile $attribute): UploadedFile|array|null\n    {\n        if ($files = $request->files->get($attribute->name ?? $argument->getName())) {\n            return !\\is_array($files) && $argument->isVariadic() ? [$files] : $files;\n        }\n\n        if ($argument->isNullable() || $argument->hasDefaultValue()) {\n            return null;\n        }\n\n        return 'array' === $argument->getType() ? [] : null;","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/symfony/http-kernel/blob/aa3a39d7286a62cdfea98f0e69c651a3da6e36cf/Controller/ArgumentResolver/RequestPayloadValueResolver.php#L268-L304","documentation":"When #[MapRequestPayload] deserializes the request body, a serializer UnsupportedFormatException means the requested format (from the Content-Type, e.g. xml, yaml) has no registered encoder/decoder. Symfony converts this into a 415 UnsupportedMediaTypeHttpException. The library throws it so clients get a standard 415 instead of an opaque serializer error.","triggerScenarios":"A controller using #[MapRequestPayload] receives a request whose Content-Type maps to a format for which no serializer encoder is configured - e.g. Content-Type: application/xml without the serializer XML encoder enabled, or an exotic Content-Type like text/csv without the CSV encoder registered.","commonSituations":"Missing/removed encoder package or framework config (framework.serializer encoders); clients sending Content-Type the API never supported; Symfony version upgrades where default encoders changed; typos in Content-Type headers.","solutions":["Make the client send a supported Content-Type (usually application/json).","Register the missing encoder in framework.yaml (e.g. enable xml: true under framework.serializer or install symfony/serializer-pack).","Check the route/format negotiation (listener Accept/Content-Type mapping) if you rely on _format.","If the format is genuinely unsupported, return 415 documentation and let clients know which media types are accepted."],"exampleFix":"# before: only json enabled\n# after: enable xml encoder\nframework:\n    serializer:\n        enabled: true\n# and install symfony/serializer + symfony/property-access encoders","handlingStrategy":"validation","validationCode":"$supported = ['json', 'xml']; // formats with registered encoders\n$format = $request->getContentTypeFormat();\nif ($format !== null && !in_array($format, $supported, true)) {\n    // avoid calling the endpoint with this format\n}","typeGuard":null,"tryCatchPattern":"try {\n    $result = $api->callWithPayload($dto);\n} catch (UnsupportedMediaTypeHttpException $e) {\n    $logger->warning('Unsupported Content-Type sent', ['ct' => $request->headers->get('Content-Type')]);\n    return new Response('Unsupported media type', 415);\n}","preventionTips":["Install symfony/serializer-pack if non-JSON formats are needed.","Keep the list of enabled encoders documented and in sync with client behavior.","Test each accepted Content-Type in CI."],"tags":["symfony","http-kernel","unsupported-media-type","serializer"],"backgroundTag":"unsupported-operation","analyzedSha":"aa3a39d7286a62cdfea98f0e69c651a3da6e36cf","analyzedAt":"2026-09-13T18:03:36.509Z","contentChangedAt":"2026-09-13T18:03:36.509Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}