{"record":{"id":"154052d95f9f311b","repo":"ory/hydra","slug":"could-not-parse-the-endpoint-url-s","errorCode":null,"errorMessage":"could not parse the endpoint URL \"%s\"","messagePattern":"could not parse the endpoint URL \"(.+?)\"","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"oryx/cmdx/http.go","lineNumber":80,"sourceCode":"\n// NewClient creates a new HTTP client.\nfunc NewClient(cmd *cobra.Command) (*http.Client, *url.URL, error) {\n\tendpoint, err := cmd.Flags().GetString(FlagEndpoint)\n\tif err != nil {\n\t\treturn nil, nil, errors.WithStack(err)\n\t}\n\n\tif endpoint == \"\" {\n\t\tendpoint = os.Getenv(envKeyEndpoint)\n\t}\n\n\tif endpoint == \"\" {\n\t\treturn nil, nil, errors.Errorf(\"you have to set the remote endpoint, try --help for details\")\n\t}\n\n\tu, err := url.Parse(strings.TrimRight(endpoint, \"/\"))\n\tif err != nil {\n\t\treturn nil, nil, errors.Wrapf(err, `could not parse the endpoint URL \"%s\"`, endpoint)\n\t}\n\n\thc := retryablehttp.NewClient().StandardClient()\n\thc.Timeout = time.Second * 10\n\n\trawHeaders, err := cmd.Flags().GetStringSlice(FlagHeaders)\n\tif err != nil {\n\t\treturn nil, nil, errors.WithStack(err)\n\t}\n\theader := http.Header{}\n\tfor _, h := range rawHeaders {\n\t\tparts := strings.Split(h, \":\")\n\t\tif len(parts) != 2 {\n\t\t\t_, _ = fmt.Fprintf(cmd.OutOrStdout(), \"Unable to parse `--http-header` flag. Format of flag value is a `: ` delimited string like `--http-header 'Some-Header: some-values; other values`. Received: %v\", rawHeaders)\n\t\t\treturn nil, nil, FailSilently(cmd)\n\t\t}\n\n\t\tfor k := range parts {","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/ory/hydra/blob/4174065ffb052799890f7480f5360a877a67ffc1/oryx/cmdx/http.go#L62-L98","documentation":"cmdx.NewClient parses the resolved endpoint URL with url.Parse after trimming trailing slashes. If parsing fails (malformed URL), the error is wrapped with this message including the raw endpoint value. Parsing rarely fails on its own — this usually indicates a garbage value like 'http://[::1' or stray characters/newlines.","triggerScenarios":"Providing an endpoint (flag or env var) that url.Parse rejects — e.g. unbalanced brackets in IPv6, control characters/whitespace/newlines in the env var, or an otherwise malformed URL string.","commonSituations":"Trailing whitespace or '\\r' in env vars set from files; copy-paste artifacts (quotes or spaces) in the endpoint; malformed IPv6 literal URLs.","solutions":["Print and inspect the endpoint value (echo \"$VAR\" | cat -A) to find hidden whitespace/control characters and correct it","Fix the URL syntax (e.g. balance IPv6 brackets: http://[::1]:4444)","Remove surrounding quotes or stray characters introduced by shell/config files","Parse the URL locally with a small Go snippet using url.Parse to confirm it is valid before retrying"],"exampleFix":"// before\nexport ORY_URL=\"https://hydra.example.com \"  # trailing space/newline\n// after\nexport ORY_URL=https://hydra.example.com","handlingStrategy":"validation","validationCode":"u, err := url.Parse(strings.TrimRight(endpoint, \"/\"))\nif err != nil {\n    return fmt.Errorf(\"endpoint %q is not a valid URL: %w\", endpoint, err)\n}","typeGuard":null,"tryCatchPattern":"client, err := cmdx.NewClient(cmd)\nif err != nil && strings.Contains(err.Error(), \"could not parse the endpoint URL\") {\n    log.Errorf(\"check ORY_URL/env value for whitespace or malformed URL: %v\", err)\n    return err\n}","preventionTips":["Inspect env var values for hidden whitespace/newlines (echo \"$VAR\" | cat -A)","Avoid quoting artifacts when exporting URLs in shell/config files","Use well-formed URLs including scheme and balanced IPv6 brackets","Validate endpoints in CI before deployment"],"tags":["cli","url","configuration","parsing"],"backgroundTag":"invalid-endpoint-url","analyzedSha":"4174065ffb052799890f7480f5360a877a67ffc1","analyzedAt":"2026-09-03T14:52:41.581Z","contentChangedAt":"2026-09-03T14:52:41.581Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}