{"record":{"id":"318f3ada97c09984","repo":"linera-io/linera-protocol","slug":"pr-number-is-none","errorCode":null,"errorMessage":"pr_number is None","messagePattern":"pr_number is None","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"linera-summary/src/github.rs","lineNumber":116,"sourceCode":"        };\n\n        // This local mode is only used for testing, so we're just hardcoding `main` as the base branch for now.\n        Ok((commit_hash, branch_name, \"main\".to_string()))\n    }\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}\"))?,","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-summary/src/github.rs#L98-L134","documentation":"In local mode, GithubContext::from_env takes commit/branch/base from the local git checkout but still needs a PR number to know which pull request to read and comment on; it has no way to derive one from git. The pr_number parameter is optional at the API boundary, and this error is the explicit refusal when it was not supplied.","triggerScenarios":"Invoking linera-summary's local mode without the PR-number argument/option, e.g. `--local` with no accompanying pr-number value.","commonSituations":"Local dry-runs of the summary tool during development; changing CLI wiring so the parsed PR number no longer reaches GithubContext::new.","solutions":["Pass the PR number when running locally, e.g. --local --pr-number 1234","If you do not have a PR yet, create one first or run in CI mode where the number comes from GITHUB_PR_NUMBER"],"exampleFix":"# before\nlinera-summary --local\n# after\nlinera-summary --local --pr-number 1234","handlingStrategy":"validation","validationCode":"// Rust: require the PR number in local mode before calling\nlet pr_number = pr_number.context(\"local mode requires an explicit PR number (--pr-number N)\")?;","typeGuard":"fn local_mode_ready(pr_number: Option<u64>) -> bool { pr_number.is_some() }","tryCatchPattern":"if let Err(e) = Github::new(true, pr_number) {\n    if e.to_string().contains(\"pr_number is None\") {\n        eprintln!(\"pass --pr-number <N> when running in local mode\");\n    }\n    return Err(e.into());\n}","preventionTips":["Make pr-number a required CLI argument whenever --local is passed (clap requires_with)","Create the PR before running local summaries so a number exists","Wrap local invocations in a make target that always supplies the number"],"tags":["linera","ci","local-mode","cli-arguments"],"backgroundTag":"missing-required-argument","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}