{"record":{"id":"8db7d5970b70eea0","repo":"linera-io/linera-protocol","slug":"github-pr-commit-hash-is-not-set-this-must-be-run","errorCode":null,"errorMessage":"GITHUB_PR_COMMIT_HASH is not set! This must be run from within CI","messagePattern":"GITHUB_PR_COMMIT_HASH is not set! This must be run from within CI","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"linera-summary/src/github.rs","lineNumber":124,"sourceCode":"        let env_pr_branch = env::var(\"GITHUB_PR_BRANCH\");\n        let env_base_branch = env::var(\"GITHUB_BASE_BRANCH\");\n        let env_pr_number = env::var(\"GITHUB_PR_NUMBER\");\n\n        let (pr_commit_hash, pr_branch, base_branch, pr_number) = if is_local {\n            let (commit_hash, branch_name, base) = Self::get_local_git_info()?;\n            (\n                commit_hash,\n                branch_name,\n                base,\n                pr_number.ok_or_else(|| anyhow!(\"pr_number is None\"))?,\n            )\n        } else {\n            let pr_string = env_pr_number.map_err(|_| {\n                anyhow!(\"GITHUB_PR_NUMBER is not set! This must be run from within CI\")\n            })?;\n            (\n                env_pr_commit_hash.map_err(|_| {\n                    anyhow!(\"GITHUB_PR_COMMIT_HASH is not set! This must be run from within CI\")\n                })?,\n                env_pr_branch.map_err(|_| {\n                    anyhow!(\"GITHUB_PR_BRANCH is not set! This must be run from within CI\")\n                })?,\n                env_base_branch.map_err(|_| {\n                    anyhow!(\"GITHUB_BASE_BRANCH is not set! This must be run from within CI\")\n                })?,\n                pr_string\n                    .parse()\n                    .map_err(|_| anyhow!(\"GITHUB_PR_NUMBER is not a valid number: {pr_string}\"))?,\n            )\n        };\n\n        Ok(Self {\n            repository: GithubRepository::from_env(is_local)?,\n            pr_commit_hash,\n            pr_branch,\n            base_branch,","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-summary/src/github.rs#L106-L142","documentation":"In CI mode, from_env reads GITHUB_PR_COMMIT_HASH — the head commit of the pull request — and fails when it is unset, because later steps compare runs and jobs against that exact commit. It is normally provided by the workflow config on pull_request events.","triggerScenarios":"A CI invocation missing GITHUB_PR_COMMIT_HASH: running outside GitHub Actions, or a workflow that forgot to export github.event.pull_request.head.sha into this variable.","commonSituations":"Custom workflow YAML that sets only some GITHUB_* variables; local emulation of CI; refactoring that renamed the export step.","solutions":["Run inside a pull_request-triggered workflow that exports GITHUB_PR_COMMIT_HASH (typically from github.event.pull_request.head.sha)","Or export it manually: GITHUB_PR_COMMIT_HASH=<full-sha> alongside the other GITHUB_PR_* variables","Check the workflow's env: block — a typo'd variable name produces exactly this failure"],"exampleFix":"# before\nenv:\n  GITHUB_PR_COMMIT: ${{ github.event.pull_request.head.sha }}\n# after\nenv:\n  GITHUB_PR_COMMIT_HASH: ${{ github.event.pull_request.head.sha }}","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\n: \"${GITHUB_PR_COMMIT_HASH:?GITHUB_PR_COMMIT_HASH is required (PR head sha)}\"","typeGuard":null,"tryCatchPattern":"if let Err(e) = Github::new(false, None) {\n    if e.to_string().contains(\"GITHUB_PR_COMMIT_HASH\") {\n        eprintln!(\"export GITHUB_PR_COMMIT_HASH=${{ github.event.pull_request.head.sha }} in the workflow env\");\n    }\n    return Err(e.into());\n}","preventionTips":["Centralize the four GITHUB_PR_*/BASE exports in one reusable env block","Name variables exactly as the tool expects — no abbreviations","Add a workflow lint that greps for all required GITHUB_* names"],"tags":["linera","ci","github-actions","environment"],"backgroundTag":"missing-env-var","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}