symfony/translation · error · IncompleteDsnException
User is not set.
Error message
User is not set.
What it means
AbstractProviderFactory::getUser extracts the username from a translation-provider DSN (e.g. a LOCO or translation vendor DSN). If the DSN has no user component, an IncompleteDsnException is thrown, since the provider cannot authenticate without credentials embedded in the DSN.
Solutions
- Add the user (usually the API key) to the DSN: 'scheme://USER@host'.
- Fix the environment variable or config file supplying the DSN so it includes the credentials.
- If the provider genuinely needs no user, verify you are using the correct scheme/factory.
- Validate the DSN with parse_url before passing it to the factory.
Example fix
// before
$provider = $factory->createProvider(new Dsn('loco://api.locoapp'));
// after
$provider = $factory->createProvider(new Dsn('loco://MY_API_KEY@api.locoapp')); Defensive patterns
Strategy: validation
Validate before calling
$params = parse_url($dsn);
if (!isset($params['user']) || '' === $params['user']) {
throw new \InvalidArgumentException('DSN must include a user (API key)');
} Try / catch
try {
$provider = $factory->createProvider(new Dsn($dsn));
} catch (IncompleteDsnException $e) {
// report missing credentials config to the operator
} Prevention
- Validate DSN shape (scheme, user, host) at config load time.
- Keep credentials in env vars and assert they are non-empty before building the DSN.
- Document the expected DSN format next to the config key.
When it happens
Trigger: Creating a provider via a factory with a DSN lacking a user part, e.g. 'somescheme://host' or 'somescheme://:password@host', when the scheme requires a user (API key).
Common situations: Env var TRANSLATION_DSN set without credentials, copying a DSN example and deleting the user portion, YAML config with scheme and host only.
Related errors
- Password is not set.
- The translation provider DSN is invalid.
- The translation provider DSN must contain a scheme.
- The translation provider DSN must contain a host (use…
- Missing required option
AI-assisted analysis of symfony/translation@ae9e8a51bc (2026-09-15).
Data as JSON: /api/errors/2a7551c5ab0ec5bf.
Report an issue: GitHub.
Appendix: source
Thrown at Provider/AbstractProviderFactory.php:30
namespace Symfony\Component\Translation\Provider;
use Symfony\Component\Translation\Exception\IncompleteDsnException;
abstract class AbstractProviderFactory implements ProviderFactoryInterface
{
public function supports(Dsn $dsn): bool
{
return \in_array($dsn->getScheme(), $this->getSupportedSchemes(), true);
}
/**
* @return string[]
*/
abstract protected function getSupportedSchemes(): array;
protected function getUser(Dsn $dsn): string
{
return $dsn->getUser() ?? throw new IncompleteDsnException('User is not set.', $dsn->getScheme().'://'.$dsn->getHost());
}
protected function getPassword(Dsn $dsn): string
{
return $dsn->getPassword() ?? throw new IncompleteDsnException('Password is not set.', $dsn->getOriginalDsn());
}
}
View on GitHub (pinned to ae9e8a51bc)