{"record":{"id":"c7948d81caa16ef3","repo":"ory/kratos","slug":"configuration-value-not-a-valid-url-s","errorCode":null,"errorMessage":"configuration value not a valid URL: %s","messagePattern":"configuration value not a valid URL: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"driver/config/config.go","lineNumber":1317,"sourceCode":"\t\t\tFatalf(\"Configuration value from key %s is not a valid URL: %s\", key, p.GetProvider(ctx).String(key))\n\t}\n\treturn parsed\n}\n\nfunc (p *Config) ParseURIOrFail(ctx context.Context, key string) *url.URL {\n\tparsed, err := p.ParseURI(p.GetProvider(ctx).String(key))\n\tif err != nil {\n\t\tp.l.WithField(\"reason\", \"expected scheme to be set\").\n\t\t\tFatalf(\"Configuration value from key %s is not a valid URL: %s\", key, p.GetProvider(ctx).String(key))\n\t}\n\treturn parsed\n}\n\nfunc (p *Config) ParseAbsoluteOrRelativeURI(rawUrl string) (*url.URL, error) {\n\tu, frag := splitUrlAndFragment(rawUrl)\n\tparsed, err := url.ParseRequestURI(u)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"configuration value not a valid URL: %s\", rawUrl)\n\t}\n\n\tif frag != \"\" {\n\t\tparsed.Fragment = frag\n\t}\n\n\treturn parsed, nil\n}\n\nfunc (p *Config) ParseURI(rawUrl string) (*url.URL, error) {\n\tparsed, err := p.ParseAbsoluteOrRelativeURI(rawUrl)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif parsed.Scheme == \"\" {\n\t\treturn nil, errors.Errorf(\"configuration value is not a valid URL: %s\", rawUrl)\n\t}\n\treturn parsed, nil","sourceCodeStart":1299,"sourceCodeEnd":1335,"githubUrl":"https://github.com/ory/kratos/blob/b86338da04a040247a07f46100a86dcfb3875909/driver/config/config.go#L1299-L1335","documentation":"Config.ParseAbsoluteOrRelativeURI validates DSN/URI configuration values by parsing them with url.ParseRequestURI. If parsing fails, the underlying parse error is wrapped with this message including the raw value. It means the configuration string is not a syntactically valid absolute or relative URI, so it cannot be used as a connection URL or endpoint.","triggerScenarios":"Calling (p *Config).ParseAbsoluteOrRelativeURI(rawUrl) where rawUrl fails url.ParseRequestURI — e.g. DSN values containing characters invalid in a URI (spaces, unescaped '%', stray quotes), values like 'host:=pass@host/db' with illegal characters, or typos such as missing scheme entirely when an absolute URL is required.","commonSituations":"Secrets/DSNs set via environment variables or config files contain shell-interpolated characters, spaces from copy-paste, unescaped special characters in passwords (e.g. '@', '#', '%' not percent-encoded), or the value is empty/garbled from a templating mistake.","solutions":["Inspect the raw value printed in the error and fix or escape invalid characters (percent-encode special characters in passwords using url.QueryEscape).","Check the environment variable / config file supplying the value for stray whitespace, quotes, or line breaks.","If a password contains special characters, use the URL-escaped form or reference it via a secret provider instead of inline in the DSN.","Validate the URI locally with url.ParseRequestURI before injecting it into config to fail fast with a clearer message."],"exampleFix":"// before (unescaped password breaks parsing)\ndsn: postgres://user:p@ss!word@localhost:5432/kratos\n\n// after (percent-encode '@' and '!')\ndsn: postgres://user:p%40ss%21word@localhost:5432/kratos","handlingStrategy":"validation","validationCode":"u, err := url.ParseRequestURI(cfg.DSN)\nif err != nil {\n    return fmt.Errorf(\"invalid DSN in config: %q: %w\", cfg.DSN, err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Percent-encode special characters in DSN passwords (url.QueryEscape).","Lint config files and env vars for stray whitespace/quotes around URLs.","Validate DSNs at deploy time with url.ParseRequestURI before the service starts."],"tags":["config","url","parsing","validation"],"backgroundTag":"invalid-url","analyzedSha":"b86338da04a040247a07f46100a86dcfb3875909","analyzedAt":"2026-09-07T15:58:15.934Z","contentChangedAt":"2026-09-07T15:58:15.934Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}