{"record":{"id":"639c95ac5735b976","repo":"FuelLabs/fuels-rs","slug":"github-token-is-not-set-in-the-environment","errorCode":null,"errorMessage":"GITHUB_TOKEN is not set in the environment","messagePattern":"GITHUB_TOKEN is not set in the environment","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/change-log/src/main.rs","lineNumber":15,"sourceCode":"use std::env;\n\nuse change_log::{\n    adapters::octocrab::OctocrabAdapter, domain::changelog::generate_changelog,\n    ports::github::GitHubPort,\n};\nuse dialoguer::FuzzySelect;\nuse dotenv::dotenv;\n\n#[tokio::main]\nasync fn main() -> Result<(), Box<dyn std::error::Error>> {\n    dotenv().ok();\n\n    let github_token =\n        env::var(\"GITHUB_TOKEN\").expect(\"GITHUB_TOKEN is not set in the environment\");\n    let repo_owner = env::var(\"GITHUB_REPOSITORY_OWNER\").unwrap_or_else(|_| \"FuelLabs\".to_string());\n    let repo_name = env::var(\"GITHUB_REPOSITORY_NAME\").unwrap_or_else(|_| \"fuels-rs\".to_string());\n\n    let github_adapter = OctocrabAdapter::new(&github_token);\n\n    let branches = {\n        let mut branches = vec![\"master\".to_string()];\n        let lts_branches = github_adapter\n            .search_branches(&repo_owner, &repo_name, \"lts/\")\n            .await?;\n        branches.extend(lts_branches);\n        branches\n    };\n\n    let branch_selection = FuzzySelect::new()\n        .with_prompt(\"Select the target branch (start typing to filter)\")\n        .items(&branches)\n        .default(0)","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/FuelLabs/fuels-rs/blob/d9a250a51818dda64bfeb5ef7cc19cf27bdcd623/scripts/change-log/src/main.rs#L1-L33","documentation":"The repository's change-log maintenance script (scripts/change-log) reads GITHUB_TOKEN from the environment after loading .env via dotenv, and panics if it is unset. The token authenticates the octocrab GitHub client used to list branches and pull requests for changelog generation.","triggerScenarios":"Running cargo run -p scripts/change-log (or the corresponding release workflow step) with GITHUB_TOKEN neither exported nor present in a .env file in the working directory.","commonSituations":"Fresh clone of the repo; CI job missing the secret; .env file never created or gitignored and lost.","solutions":["Create a .env file in the directory you run the script from containing GITHUB_TOKEN=<token>","Export GITHUB_TOKEN in the shell or add the secret to the CI job environment","Use a fine-grained personal access token with read access to the repository"],"exampleFix":"# before\n$ cargo run -p scripts/change-log\n# panics: GITHUB_TOKEN is not set in the environment\n\n# after\n$ echo 'GITHUB_TOKEN=ghp_yourtoken' > .env\ncargo run -p scripts/change-log","handlingStrategy":"validation","validationCode":"# (shell) check before running the script\n[ -n \"$GITHUB_TOKEN\" ] || { echo 'GITHUB_TOKEN missing'; exit 1; }\n# or persist it: echo 'GITHUB_TOKEN=ghp_xxx' >> .env","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Create a .env file in the script's working directory with GITHUB_TOKEN","Expose GITHUB_TOKEN as a CI secret on jobs that generate the changelog","Use a fine-grained PAT with minimal read scopes and rotate it"],"tags":["scripting","environment","github","release-tooling"],"backgroundTag":null,"analyzedSha":"d9a250a51818dda64bfeb5ef7cc19cf27bdcd623","analyzedAt":"2026-08-16T09:49:30.618Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}