{"record":{"id":"0606b93052fcd378","repo":"hasura/graphql-engine","slug":"error-validating-endpoint-url-w","errorCode":null,"errorMessage":"error validating endpoint URL: %w","messagePattern":"error validating endpoint URL: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/commands/init.go","lineNumber":271,"sourceCode":"\terr := os.MkdirAll(filepath.Dir(o.EC.ExecutionDirectory), os.ModePerm)\n\tif err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"error creating setup directories: %w\", err))\n\t}\n\t// set config object\n\tconfig := &cli.Config{\n\t\tVersion: o.Version,\n\t\tServerConfig: cli.ServerConfig{\n\t\t\tEndpoint: defaultEndpoint,\n\t\t},\n\t\tMetadataDirectory: \"metadata\",\n\t\tActionConfig: &actionMetadataFileTypes.ActionExecutionConfig{\n\t\t\tKind:                  \"synchronous\",\n\t\t\tHandlerWebhookBaseURL: \"http://localhost:3000\",\n\t\t},\n\t}\n\tif o.Endpoint != \"\" {\n\t\tif _, err := url.ParseRequestURI(o.Endpoint); err != nil {\n\t\t\treturn errors.E(op, fmt.Errorf(\"error validating endpoint URL: %w\", err))\n\t\t}\n\n\t\tconfig.Endpoint = o.Endpoint\n\t}\n\n\tif o.AdminSecret != \"\" {\n\t\tconfig.AdminSecret = o.AdminSecret\n\t}\n\n\t// write the config file\n\to.EC.Config = config\n\to.EC.ConfigFile = filepath.Join(o.EC.ExecutionDirectory, \"config.yaml\")\n\n\terr = o.EC.WriteConfig(nil)\n\tif err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"cannot write config file: %w\", err))\n\t}\n","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/commands/init.go#L253-L289","documentation":"The --endpoint value passed to `hasura init` failed url.ParseRequestURI validation. The CLI requires an absolute request URI, so relative or malformed endpoint strings are rejected before being written into config.yaml.","triggerScenarios":"`hasura init --endpoint localhost:8080` (no scheme), `--endpoint /hasura`, or any string that is not a valid absolute URI.","commonSituations":"Forgetting the http:// or https:// scheme; trailing junk/whitespace in the endpoint; copying endpoint with unescaped characters.","solutions":["Supply a fully-qualified URI including scheme: `--endpoint https://hasura.example.com`","Trim whitespace and URL-encode special characters in the endpoint","If using a local server, use http://localhost:8080 explicitly"],"exampleFix":"// before\nhasura init myproject --endpoint localhost:8080\n// after\nhasura init myproject --endpoint http://localhost:8080","handlingStrategy":"validation","validationCode":"u, err := url.ParseRequestURI(endpoint)\nif err != nil || (u.Scheme != \"http\" && u.Scheme != \"https\") || u.Host == \"\" {\n    log.Fatalf(\"endpoint must be an absolute http(s) URL, got %q\", endpoint)\n}","typeGuard":"func isValidEndpoint(s string) bool {\n    u, err := url.ParseRequestURI(s)\n    return err == nil && u.Host != \"\" && (u.Scheme == \"http\" || u.Scheme == \"https\")\n}","tryCatchPattern":null,"preventionTips":["Always include the scheme in --endpoint","Validate URLs in CI config before invoking init"],"tags":["hasura","cli","init","url-validation","endpoint"],"backgroundTag":"invalid-url-format","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}