{"record":{"id":"24eb1e5f31156827","repo":"linera-io/linera-protocol","slug":"github-pr-number-is-not-set-this-must-be-run-from","errorCode":null,"errorMessage":"GITHUB_PR_NUMBER is not set! This must be run from within CI","messagePattern":"GITHUB_PR_NUMBER 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":120,"sourceCode":"    }\n\n    fn from_env(is_local: bool, pr_number: Option<u64>) -> Result<Self> {\n        let env_pr_commit_hash = env::var(\"GITHUB_PR_COMMIT_HASH\");\n        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 {","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-summary/src/github.rs#L102-L138","documentation":"In CI mode, GithubContext::from_env reads GITHUB_PR_NUMBER to identify the pull request; GitHub Actions sets it on pull_request events, and the tool treats its absence as 'not actually running in a PR CI context', failing fast.","triggerScenarios":"Running the summary workflow on a push event or workflow_dispatch (no PR context), or outside GitHub Actions without exporting the variable.","commonSituations":"Adding the summary step to a workflow whose triggers include push; manual workflow_dispatch runs; runners with a minimal environment.","solutions":["Restrict the summary job to pull_request triggers in the workflow (if: github.event_name == 'pull_request')","Or export a valid number: GITHUB_PR_NUMBER=42 with the other GITHUB_* variables","Use pull_request_target/pull_request workflows where the variable is populated"],"exampleFix":"# before\non: [push, pull_request]\n# after\non: [pull_request]","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\n# Fail fast before running the summary step in CI mode\n: \"${GITHUB_PR_NUMBER:?GITHUB_PR_NUMBER is required; run under a pull_request workflow}\"","typeGuard":null,"tryCatchPattern":"if let Err(e) = Github::new(false, None) {\n    if e.to_string().contains(\"GITHUB_PR_NUMBER\") {\n        eprintln!(\"no PR context; restrict this job to pull_request events\");\n    }\n    return Err(e.into());\n}","preventionTips":["Condition summary jobs on github.event_name == 'pull_request'","Use :\"${VAR:?}\" guards in scripts that emulate CI","Remember a nonzero numeric value is also required — a non-numeric value fails the sibling parse error"],"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"}