{"record":{"id":"67a41a31bffc8cc8","repo":"unslothai/unsloth","slug":"github-token-is-required-set-it-in-the-recipe-con","errorCode":null,"errorMessage":"GitHub token is required. Set it in the recipe config or the GH_TOKEN / GITHUB_TOKEN env var.","messagePattern":"GitHub token is required\\. Set it in the recipe config or the GH_TOKEN / GITHUB_TOKEN env var\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"studio/backend/plugins/data-designer-github-repo-seed/src/data_designer_github_repo_seed/scraper.py","lineNumber":72,"sourceCode":"\n\ndef _resolve_token(token: str) -> ResolvedToken:\n    if token:\n        return ResolvedToken(\n            value = token,\n            source = \"explicit token argument (recipe-level field)\",\n        )\n    if os.environ.get(\"GH_TOKEN\"):\n        return ResolvedToken(\n            value = os.environ[\"GH_TOKEN\"],\n            source = \"GH_TOKEN environment variable\",\n        )\n    if os.environ.get(\"GITHUB_TOKEN\"):\n        return ResolvedToken(\n            value = os.environ[\"GITHUB_TOKEN\"],\n            source = \"GITHUB_TOKEN environment variable\",\n        )\n    raise ValueError(\n        \"GitHub token is required. Set it in the recipe config or the GH_TOKEN / GITHUB_TOKEN env var.\"\n    )\n\n\ndef _read_jsonl(path: Path, max_rows: int | None = None):\n    if not path.exists():\n        return\n    with path.open(encoding = \"utf-8\") as f:\n        for i, line in enumerate(f):\n            if not line.strip():\n                continue\n            if max_rows is not None and i >= max_rows:\n                return\n            try:\n                yield json.loads(line)\n            except json.JSONDecodeError:\n                continue\n","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/plugins/data-designer-github-repo-seed/src/data_designer_github_repo_seed/scraper.py#L54-L90","documentation":"Raised by the GitHub repo seed scraper's token resolution (_resolve_token) when no GitHub token can be found. Resolution order: explicit recipe-level token argument, then GH_TOKEN env var, then GITHUB_TOKEN env var; if all are absent a ValueError is raised telling the user exactly where to supply one. The GitHub API requires authentication for the GraphQL and rate-limited REST calls this scraper makes.","triggerScenarios":"Running the data-designer-github-repo-seed scraper without a token field in the recipe config and with neither GH_TOKEN nor GITHUB_TOKEN exported in the environment (e.g. in a container or CI job that forgot the secret).","commonSituations":"Local run works (token in shell rc file) but the same job fails in Docker/CI where env vars are not passed; token set under a different variable name (GITHUB_ACCESS_TOKEN, GH_PAT); recipe YAML missing the token field.","solutions":["Export GH_TOKEN or GITHUB_TOKEN with a personal access token before running: export GH_TOKEN=ghp_...","Or set the token field in the recipe config so it is passed as the explicit token argument.","In CI/Docker, ensure the secret is actually injected into the environment (check with a masked env dump)."],"exampleFix":"# before\n$ python -m data_designer_github_repo_seed ...  # no token anywhere\n\n# after\n$ export GH_TOKEN=\"ghp_xxxx\"\n$ python -m data_designer_github_repo_seed ...","handlingStrategy":"validation","validationCode":"import os\n\ndef github_token_available(config: dict | None = None) -> bool:\n    if config and config.get(\"token\"):\n        return True\n    return bool(os.environ.get(\"GH_TOKEN\") or os.environ.get(\"GITHUB_TOKEN\"))","typeGuard":null,"tryCatchPattern":"try:\n    run_seed(recipe)\nexcept ValueError as e:\n    if \"GitHub token is required\" in str(e):\n        sys.exit(\"Set GH_TOKEN or GITHUB_TOKEN, or add 'token:' to the recipe, then retry.\")\n    raise","preventionTips":["Check token presence at job submission time, not mid-scrape.","Wire the secret through CI/Docker env explicitly; do not rely on interactive shell rc files."],"tags":["github","authentication","environment","secrets"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}