{"record":{"id":"5f7e061786cb68af","repo":"urfave/cli","slug":"empty-github-token","errorCode":null,"errorMessage":"empty github token","messagePattern":"empty github token","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/build.go","lineNumber":614,"sourceCode":"\t}\n\n\tif err := runCmd(ctx, \"mkdocs\", \"--version\"); err == nil {\n\t\treturn nil\n\t}\n\n\tif cmd.Bool(\"upgrade-pip\") {\n\t\tif err := runCmd(ctx, \"pip\", \"install\", \"-U\", \"pip\"); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn runCmd(ctx, \"pip\", \"install\", \"-r\", \"mkdocs-requirements.txt\")\n}\n\nfunc SetMkdocsRemoteActionFunc(ctx context.Context, cmd *cli.Command) error {\n\tghToken := strings.TrimSpace(cmd.String(\"github-token\"))\n\tif ghToken == \"\" {\n\t\treturn errors.New(\"empty github token\")\n\t}\n\n\tif err := os.Chdir(cmd.String(\"top-dir\")); err != nil {\n\t\treturn err\n\t}\n\n\tif err := runCmd(ctx, \"git\", \"remote\", \"rm\", \"origin\"); err != nil {\n\t\treturn err\n\t}\n\n\treturn runCmd(\n\t\tctx,\n\t\t\"git\", \"remote\", \"add\", \"origin\",\n\t\tfmt.Sprintf(\"https://x-access-token:%[1]s@github.com/urfave/cli.git\", ghToken),\n\t)\n}\n\nfunc LintActionFunc(ctx context.Context, cmd *cli.Command) error {","sourceCodeStart":596,"sourceCodeEnd":632,"githubUrl":"https://github.com/urfave/cli/blob/1a4deb4f5a35ee12706602698dc0527d44c14b19/scripts/build.go#L596-L632","documentation":"SetMkdocsRemoteActionFunc validates the --github-token command option before performing GitHub remote configuration for docs builds. If the option is missing or contains only whitespace (it is TrimSpace'd first), the action aborts with this error because a GitHub API token is required to set up the remote.","triggerScenarios":"Running the build tooling's mkdocs remote action without passing --github-token, or passing it an empty/whitespace-only value (e.g. GH_TOKEN env var is unset and expanded to empty in a shell script).","commonSituations":"CI pipelines where the secret (e.g. secrets.GITHUB_TOKEN) is not wired into the workflow step, local runs without exporting the token, or quoting mistakes yielding an empty string.","solutions":["Pass the token: --github-token \"$GH_TOKEN\" with the environment variable exported, or provide the value directly in CI secret configuration.","Verify the CI workflow actually maps the secret (e.g. env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}) to the step.","Check for typos in the variable name that would expand to an empty string."],"exampleFix":"// before\nrun: ./build mkdocs-remote --github-token \"\"\n// after\nrun: ./build mkdocs-remote --github-token \"${{ secrets.GITHUB_TOKEN }}\"","handlingStrategy":"validation","validationCode":"token := os.Getenv(\"GH_TOKEN\")\nif strings.TrimSpace(token) == \"\" {\n\treturn errors.New(\"GH_TOKEN must be set before running mkdocs remote setup\")\n}","typeGuard":null,"tryCatchPattern":"if err := action(ctx, cmd); err != nil {\n\tif strings.Contains(err.Error(), \"empty github token\") {\n\t\treturn fmt.Errorf(\"provide --github-token or set GH_TOKEN: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["In CI, map the secret into the step env explicitly (env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}).","Fail fast at pipeline start if the token variable is unset/empty.","Avoid interpolating possibly-empty shell variables into --github-token; check with ${GH_TOKEN:?}."],"tags":["go","ci","github","configuration"],"backgroundTag":"missing-env-var","analyzedSha":"1a4deb4f5a35ee12706602698dc0527d44c14b19","analyzedAt":"2026-08-31T18:42:09.451Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}