{"record":{"id":"d33af772ff2e0704","repo":"mislav/hub","slug":"aborting-due-to-empty-pull-request-title","errorCode":null,"errorMessage":"Aborting due to empty pull request title","messagePattern":"Aborting due to empty pull request title","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/pull_request.go","lineNumber":315,"sourceCode":"\t\t\t}\n\t\t}\n\n\t\tworkdir, _ := git.WorkdirName()\n\t\tif workdir != \"\" {\n\t\t\ttemplate, _ := github.ReadTemplate(github.PullRequestTemplate, workdir)\n\t\t\tif template != \"\" {\n\t\t\t\tmessage = message + \"\\n\\n\\n\" + template\n\t\t\t}\n\t\t}\n\n\t\tmessageBuilder.Message = message\n\t}\n\n\ttitle, body, err := messageBuilder.Extract()\n\tutils.Check(err)\n\n\tif title == \"\" && flagPullRequestIssue == \"\" {\n\t\tutils.Check(fmt.Errorf(\"Aborting due to empty pull request title\"))\n\t}\n\n\tif flagPullRequestPush {\n\t\tif args.Noop {\n\t\t\targs.Before(fmt.Sprintf(\"Would push to %s/%s\", remote.Name, head), \"\")\n\t\t} else {\n\t\t\terr = git.Spawn(\"push\", \"--set-upstream\", remote.Name, fmt.Sprintf(\"HEAD:%s\", head))\n\t\t\tutils.Check(err)\n\t\t}\n\t}\n\n\tmilestoneNumber, err := milestoneValueToNumber(args.Flag.Value(\"--milestone\"), client, baseProject)\n\tutils.Check(err)\n\n\tvar pullRequestURL string\n\tif args.Noop {\n\t\targs.Before(fmt.Sprintf(\"Would request a pull request to %s from %s\", fullBase, fullHead), \"\")\n\t\tpullRequestURL = \"PULL_REQUEST_URL\"","sourceCodeStart":297,"sourceCodeEnd":333,"githubUrl":"https://github.com/mislav/hub/blob/5c547ed804368763064e51f3990851e267e88edd/commands/pull_request.go#L297-L333","documentation":"After extracting the title and body from the user's editor/`--file`/commit message, pullRequest validates that a non-empty title was provided. If the title is blank (and no issue number was given to attach the PR to), the PR cannot be created, so it aborts with this error.","triggerScenarios":"`gh pr create` where `messageBuilder.Extract()` returns title == \"\" and flagPullRequestIssue == \"\" — the first block of the edited message was left empty, the `--file` body starts with no title line, or the commit subject is empty.","commonSituations":"Deleting all text in the interactive editor before saving; a --file template whose first line is blank; creating a PR for an issue without supplying the issue flag; commit messages with only a body.","solutions":["Provide a title: fill in the first line of the editor message, or pass it via the CLI title flag.","Fix the --file input so the first block (before a blank line) is a non-empty title.","If attaching to an existing issue, pass the issue flag (e.g. `gh pr create -i <issue>`) instead of a title."],"exampleFix":"// before: message file starting with a blank line\n\"\"\n\"Fix login bug...\"\n// after\n\"Fix login bug\"\n\"Add validation to the login handler...\"","handlingStrategy":"validation","validationCode":"title, body, err := messageBuilder.Extract()\nif err != nil {\n    return err\n}\nif strings.TrimSpace(title) == \"\" {\n    return errors.New(\"provide a non-empty PR title (first line of message)\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never clear the first line of the PR editor message.","Ensure --file inputs start with a title line.","Pass an explicit title or issue flag in scripts."],"tags":["pull-request","validation","cli"],"backgroundTag":"empty-required-field","analyzedSha":"5c547ed804368763064e51f3990851e267e88edd","analyzedAt":"2026-09-01T03:34:15.525Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}