{"record":{"id":"89736976fdb23321","repo":"symfony/translation","slug":"the-translation-provider-dsn-must-contain-a-host-use-default","errorCode":null,"errorMessage":"The translation provider DSN must contain a host (use \"default\" by default).","messagePattern":"The translation provider DSN must contain a host \\(use \"default\" by default\\)\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"Provider/Dsn.php","lineNumber":46,"sourceCode":"    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;\n    }\n\n    public function getHost(): string\n    {\n        return $this->host;","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/symfony/translation/blob/ae9e8a51bc29780d63c7f9efd6005d7c875e100b/Provider/Dsn.php#L28-L64","documentation":"Dsn requires a host component after scheme validation. Without a host the factory cannot target the provider API, so InvalidArgumentException is thrown; the message hints that \"default\" may be used where a provider accepts it.","triggerScenarios":"new Dsn('loco://key@') or DSNs ending right after credentials with no host, e.g. 'scheme://user:pass@' or a truncated DSN in an env var.","commonSituations":"Templated DSN where the host variable was empty, cutting the string at '@' when copying credentials, or writing 'loco://key' assuming a default host exists for every provider.","solutions":["Add the provider's host to the DSN: 'scheme://key@host'.","Use 'default' as the host when the provider factory supports it (e.g. 'loco://KEY@default').","Check the env var/config for a truncated value (commonly missing after '@').","Look up the correct host in the provider factory's docs or tests for the scheme you use."],"exampleFix":"// before\nnew Dsn('loco://API_KEY@');\n\n// after\nnew Dsn('loco://API_KEY@default');","handlingStrategy":"validation","validationCode":"$params = parse_url($dsn);\nif (!isset($params['host']) || '' === $params['host']) {\n    throw new \\InvalidArgumentException('DSN must include a host (use \"default\" if supported)');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $dsn = new Dsn($rawDsn);\n} catch (\\InvalidArgumentException $e) {\n    // append the provider host or 'default' before retrying\n}","preventionTips":["Include the host in every DSN, even when using the 'default' placeholder.","Check for truncated env vars — content is often lost right after '@'.","Copy the DSN template from the provider factory's documentation verbatim."],"tags":["dsn","url-parsing","translation-provider","missing-host"],"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"}