From 456547c48a17531eb02270739c66225f16162927 Mon Sep 17 00:00:00 2001 From: Josh Johanning Date: Wed, 1 Oct 2025 14:00:29 -0500 Subject: [PATCH] fix: enhance error handling for insufficient scopes in project board script --- gh-cli/get-project-board-items.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/gh-cli/get-project-board-items.sh b/gh-cli/get-project-board-items.sh index 793f7c3..f38529a 100755 --- a/gh-cli/get-project-board-items.sh +++ b/gh-cli/get-project-board-items.sh @@ -10,6 +10,7 @@ if [ $# -ne 2 ]; then echo "Usage: $0 " echo "Example: ./get-project-board-items.sh my-org 123" + echo "Example: ./get-project-board-items.sh my-org 123" > results.txt echo "" echo "Note: This script works with Projects V2 (the newer project boards)" echo "To find project number, check the URL: github.com/orgs/ORG/projects/NUMBER" @@ -145,7 +146,26 @@ response=$(gh api graphql --paginate -f org="$org" -F projectNumber="$project_nu # Check for errors if [ $? -ne 0 ]; then - if echo "$response" | grep -q "Could not resolve to a ProjectV2"; then + if echo "$response" | grep -q "INSUFFICIENT_SCOPES"; then + echo "❌ Error: Your GitHub token doesn't have the required permissions" + echo "" + echo "🔐 Required scope: 'read:project'" + echo "" + echo "Your token currently has these scopes:" + # Extract current scopes from the error message + current_scopes=$(echo "$response" | grep -o "but your token has only been granted the: \[.*\]" | sed "s/.*\[\(.*\)\].*/\1/" | tr ',' '\n' | sed "s/['\", ]//g" | grep -v "^$" | sort | uniq) + if [ -n "$current_scopes" ]; then + echo "$current_scopes" | sed 's/^/ â€ĸ /' + else + echo " â€ĸ (Unable to determine current scopes)" + fi + echo "" + echo "📝 To fix this issue, run:" + echo " gh auth refresh -h github.com -s read:project" + echo "" + echo "â„šī¸ If using a PAT, go update the permissions to include the 'read:project' scope." + exit 1 + elif echo "$response" | grep -q "Could not resolve to a ProjectV2"; then echo "❌ Error: Project #$project_number not found in organization '$org'" echo "Make sure:" echo "- The project number is correct"