{"record":{"id":"aaa6c1ee1452a565","repo":"cli/cli","slug":"cannot-open-in-browser-maximum-url-length-exceede","errorCode":null,"errorMessage":"cannot open in browser: maximum URL length exceeded","messagePattern":"cannot open in browser: maximum URL length exceeded","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/issue/create/create.go","lineNumber":234,"sourceCode":"\tif opts.RecoverFile != \"\" {\n\t\terr = prShared.FillFromJSON(opts.IO, opts.RecoverFile, &tb)\n\t\tif err != nil {\n\t\t\terr = fmt.Errorf(\"failed to recover input: %w\", err)\n\t\t\treturn\n\t\t}\n\t}\n\n\ttpl := prShared.NewTemplateManager(httpClient, baseRepo, opts.Prompter, opts.RootDirOverride, !opts.HasRepoOverride, false)\n\n\tif opts.WebMode {\n\t\tvar openURL string\n\t\tif opts.Title != \"\" || opts.Body != \"\" || tb.HasMetadata() {\n\t\t\topenURL, err = generatePreviewURL(apiClient, baseRepo, tb, projectsV1Support)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif !prShared.ValidURL(openURL) {\n\t\t\t\terr = fmt.Errorf(\"cannot open in browser: maximum URL length exceeded\")\n\t\t\t\treturn\n\t\t\t}\n\t\t} else if ok, _ := tpl.HasTemplates(); ok {\n\t\t\topenURL = ghrepo.GenerateRepoURL(baseRepo, \"issues/new/choose\")\n\t\t} else {\n\t\t\topenURL = ghrepo.GenerateRepoURL(baseRepo, \"issues/new\")\n\t\t}\n\t\tif isTerminal {\n\t\t\tfmt.Fprintf(opts.IO.ErrOut, \"Opening %s in your browser.\\n\", text.DisplayURL(openURL))\n\t\t}\n\t\treturn opts.Browser.Browse(openURL)\n\t}\n\n\tif isTerminal {\n\t\tfmt.Fprintf(opts.IO.ErrOut, \"\\nCreating issue in %s\\n\\n\", ghrepo.FullName(baseRepo))\n\t}\n\n\trepo, err := api.IssueRepoInfo(apiClient, baseRepo)","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/cli/cli/blob/0eeec0b92edbe70199f9768522f831d3534f41ad/pkg/cmd/issue/create/create.go#L216-L252","documentation":"Thrown by gh issue create --web when the preview URL built from the provided title/body/metadata exceeds prShared.ValidURL's maximum length. Browsers and the Browse call cannot reliably handle arbitrarily long URLs, so gh refuses instead of opening a broken page.","triggerScenarios":"`gh issue create --web` with a very large --body (e.g. contents of a huge log pasted or `--body-file` of a large file) plus title/labels; generatePreviewURL encodes everything into query parameters and the result crosses the limit.","commonSituations":"Piping whole log files into --body, using --web with machine-generated diagnostics, or reusing a command line that worked until the body grew past the threshold.","solutions":["Shorten the body or reference an attached file instead of inlining it.","Drop --web and create the issue directly: `gh issue create --title ... --body-file ...` (no URL length limit applies).","If a browser flow is required, create with a short placeholder body, then edit the issue on github.com and paste the long content there."],"exampleFix":"# before\ngh issue create --web --title \"crash\" --body \"$(cat 5mb.log)\"\n# gh: cannot open in browser: maximum URL length exceeded\n\n# after\ngh issue create --title \"crash\" --body-file 5mb.log","handlingStrategy":"validation","validationCode":"// Keep the body under the URL budget when using --web:\nconst maxURLLen = 8219 // prShared.ValidURL bound\nfunc fitsWebURL(title, body string, metaLen int) bool {\n\t// URL-encoding roughly triples worst-case payloads; use a conservative check\n\treturn len(title)+len(body)+metaLen < maxURLLen/3\n}","typeGuard":"func validURL(u string) bool {\n\treturn len(u) < 8219\n}","tryCatchPattern":"if err := createRun(opts); err != nil {\n\tif err.Error() == \"cannot open in browser: maximum URL length exceeded\" {\n\t\t// retry without --web: create directly with --title/--body-file\n\t}\n}","preventionTips":["Avoid --web for bodies over a few KB; create directly and let gh POST the content.","Attach large logs as files rather than inlining them into --body.","In automation, prefer the non-web path unconditionally."],"tags":["issue","web-mode","url-length","limits"],"backgroundTag":null,"analyzedSha":"0eeec0b92edbe70199f9768522f831d3534f41ad","analyzedAt":"2026-08-15T12:31:05.478Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}