{"record":{"id":"015df4e8eb25d31e","repo":"cli/cli","slug":"no-license-provided","errorCode":null,"errorMessage":"no license provided","messagePattern":"no license provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/repo/license/view/view.go","lineNumber":77,"sourceCode":"\t\t`),\n\t\tArgs: cobra.ExactArgs(1),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\topts.License = args[0]\n\t\t\tif runF != nil {\n\t\t\t\treturn runF(opts)\n\t\t\t}\n\t\t\treturn viewRun(opts)\n\t\t},\n\t}\n\n\tcmd.Flags().BoolVarP(&opts.Web, \"web\", \"w\", false, \"Open https://choosealicense.com/ in the browser\")\n\n\treturn cmd\n}\n\nfunc viewRun(opts *ViewOptions) error {\n\tif opts.License == \"\" {\n\t\treturn errors.New(\"no license provided\")\n\t}\n\n\tclient, err := opts.HTTPClient()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcfg, err := opts.Config()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := opts.IO.StartPager(); err != nil {\n\t\tfmt.Fprintf(opts.IO.ErrOut, \"starting pager failed: %v\\n\", err)\n\t}\n\tdefer opts.IO.StopPager()\n\n\thostname, _ := cfg.Authentication().DefaultHost()","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/cli/cli/blob/0eeec0b92edbe70199f9768522f831d3534f41ad/pkg/cmd/repo/license/view/view.go#L59-L95","documentation":"Simple argument check in `gh repo license view`: the license keyword (the sole positional argument) is required; with an empty license the command stops immediately before contacting the API. The license must be one of the keys GitHub's licenses API accepts (e.g. mit, apache-2.0, agpl-3.0).","triggerScenarios":"Running `gh repo license view` without a positional argument outside the interactive picker, or calling viewRun with an empty License field. Passing an invalid (non-empty) license instead produces a server 404, not this error.","commonSituations":"Scripts omitting the argument or passing an unset shell variable; users expecting --web alone to work without specifying a license.","solutions":["Pass a license keyword: gh repo license view mit","List valid keywords: gh api /licenses -q '.[].key'","Default script variables: \"${LICENSE:-mit}\""],"exampleFix":"# before\ngh repo license view\n# after\ngh repo license view mit","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(licenseKey) == \"\" {\n    return errors.New(\"license key is required, e.g. gh repo license view mit\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate non-empty arguments before invoking gh in scripts","List valid keys: gh api /licenses -q '.[].key'","Default the variable: \"${LICENSE:-mit}\""],"tags":["license","missing-argument","input-validation","cli"],"backgroundTag":null,"analyzedSha":"0eeec0b92edbe70199f9768522f831d3534f41ad","analyzedAt":"2026-08-15T12:31:05.478Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}