{"record":{"id":"4e1a678370341cc4","repo":"symfony/translation","slug":"the-translation-provider-dsn-must-contain-a-scheme","errorCode":null,"errorMessage":"The translation provider DSN must contain a scheme.","messagePattern":"The translation provider DSN must contain a scheme\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"Provider/Dsn.php","lineNumber":41,"sourceCode":"    private ?string $scheme;\n    private ?string $host;\n    private ?string $user;\n    private ?string $password;\n    private ?int $port;\n    private ?string $path;\n    private array $options = [];\n    private string $originalDsn;\n\n    public function __construct(#[\\SensitiveParameter] string $dsn)\n    {\n        $this->originalDsn = $dsn;\n\n        if (false === $params = parse_url($dsn)) {\n            throw new InvalidArgumentException('The translation provider DSN is invalid.');\n        }\n\n        if (!isset($params['scheme'])) {\n            throw new InvalidArgumentException('The translation provider DSN must contain a scheme.');\n        }\n        $this->scheme = $params['scheme'];\n\n        if (!isset($params['host'])) {\n            throw new InvalidArgumentException('The translation provider DSN must contain a host (use \"default\" by default).');\n        }\n        $this->host = $params['host'];\n\n        $this->user = '' !== ($params['user'] ?? '') ? rawurldecode($params['user']) : null;\n        $this->password = '' !== ($params['pass'] ?? '') ? rawurldecode($params['pass']) : null;\n        $this->port = $params['port'] ?? null;\n        $this->path = $params['path'] ?? null;\n        parse_str($params['query'] ?? '', $this->options);\n    }\n\n    public function getScheme(): string\n    {\n        return $this->scheme;","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/symfony/translation/blob/ae9e8a51bc29780d63c7f9efd6005d7c875e100b/Provider/Dsn.php#L23-L59","documentation":"After parse_url succeeds, Dsn requires a scheme component. A DSN like '://host' or '//host' (protocol-relative) has no scheme, so the factory cannot know which translation provider to instantiate; InvalidArgumentException is thrown.","triggerScenarios":"new Dsn('//host') or a scheme-less DSN string reaching any translation provider factory; env var set to a host-only value; template/config dropping the 'scheme://' prefix.","commonSituations":"Config values like 'loco-host' without 'loco://', stripping the scheme while joining URL parts, or defaults written as '//default'.","solutions":["Prefix the DSN with its scheme, e.g. 'loco://...'.","Check that config interpolation didn't consume the '//' separator.","Use the exact scheme supported by the factory (see getSupportedSchemes of the intended provider).","Validate the DSN starts with a scheme followed by '://' before constructing."],"exampleFix":"// before\nnew Dsn('//api.locoapp');\n\n// after\nnew Dsn('loco://api.locoapp');","handlingStrategy":"validation","validationCode":"if (!str_contains($dsn, '://')) {\n    throw new \\InvalidArgumentException('DSN must include a scheme, e.g. loco://...');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $dsn = new Dsn($rawDsn);\n} catch (\\InvalidArgumentException $e) {\n    // prepend the correct scheme or fix the config value\n}","preventionTips":["Always write DSNs with an explicit scheme:// prefix.","Check config templates for separators consumed by interpolation.","Validate against the provider factory's supported schemes."],"tags":["dsn","url-parsing","translation-provider","missing-scheme"],"backgroundTag":"invalid-url-format","analyzedSha":"ae9e8a51bc29780d63c7f9efd6005d7c875e100b","analyzedAt":"2026-09-15T22:29:15.305Z","contentChangedAt":"2026-09-15T22:29:15.305Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}