{"record":{"id":"b7472a08f73c873b","repo":"symfony/symfony","slug":"using-the-json-format-to-debug-environment-variabl","errorCode":null,"errorMessage":"Using the JSON format to debug environment variables is not supported.","messagePattern":"Using the JSON format to debug environment variables is not supported\\.","errorType":"console","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php","lineNumber":167,"sourceCode":"    {\n        $this->writeData($this->getCallableData($callable), $options);\n    }\n\n    protected function describeContainerParameter(mixed $parameter, ?array $deprecation, array $options = []): void\n    {\n        $key = $options['parameter'] ?? '';\n        $data = [$key => $parameter];\n\n        if ($deprecation) {\n            $data['_deprecation'] = \\sprintf('Since %s %s: %s', $deprecation[0], $deprecation[1], \\sprintf(...\\array_slice($deprecation, 2)));\n        }\n\n        $this->writeData($data, $options);\n    }\n\n    protected function describeContainerEnvVars(array $envs, array $options = []): void\n    {\n        throw new LogicException('Using the JSON format to debug environment variables is not supported.');\n    }\n\n    protected function describeContainerDeprecations(ContainerBuilder $container, array $options = []): void\n    {\n        $containerDeprecationFilePath = \\sprintf('%s/%sDeprecations.log', $container->getParameter('kernel.build_dir'), $container->getParameter('kernel.container_class'));\n        if (!file_exists($containerDeprecationFilePath)) {\n            throw new RuntimeException('The deprecation file does not exist, please try warming the cache first.');\n        }\n\n        $logs = unserialize(file_get_contents($containerDeprecationFilePath), ['allowed_classes' => false]);\n\n        $formattedLogs = [];\n        $remainingCount = 0;\n        foreach ($logs as $log) {\n            $formattedLogs[] = [\n                'message' => $log['message'],\n                'file' => $log['file'],\n                'line' => $log['line'],","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/symfony/symfony/blob/698e28026c22cf35d032cdb6e800db48b1535790/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php#L149-L185","documentation":"Thrown by `JsonDescriptor::describeContainerEnvVars()` when the `debug:container` command is asked to list environment variables (`--env-vars` or `--env-var`) using the `--format=json` output. Environment-variable debugging relies on runtime introspection that only the text descriptor implements, so the JSON descriptor rejects it with a `LogicException`.","triggerScenarios":"Running `php bin/console debug:container --env-vars --format=json` or `debug:container --env-var=APP_ENV --format=json`. The JSON descriptor's `describeContainerEnvVars` override unconditionally throws.","commonSituations":"Scripting/CI pipelines that default to `--format=json` for machine-readable output and try to inspect env vars with the same flag.","solutions":["Use the default text format (`--format=txt` or omit `--format`) for env-var debugging.","Parse the text output in your script, or read env vars directly via `$_SERVER`/`getenv()` instead of the command."],"exampleFix":"// before\nphp bin/console debug:container --env-vars --format=json\n\n// after\nphp bin/console debug:container --env-vars","handlingStrategy":"validation","validationCode":"// Never combine --env-vars with --format=json.\n$format = $input->getOption('format');\nif (($input->getOption('env-vars') || $input->getOption('env-var')) && $format === 'json') {\n    // switch to txt or remove env-vars\n}","typeGuard":null,"tryCatchPattern":"try {\n    $command->run($input, $output);\n} catch (\\Symfony\\Component\\Console\\Exception\\LogicException $e) {\n    // unsupported format combo; retry with txt\n}","preventionTips":["Remember env-var debugging is text-only across all descriptor formats.","Read env vars via `getenv()` in scripts instead of parsing command JSON."],"tags":["symfony","console","descriptor","json","environment-variables"],"analyzedSha":"698e28026c22cf35d032cdb6e800db48b1535790","analyzedAt":"2026-08-06T23:40:49.025Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}