@@ -39,6 +39,17 @@ if [ -z "$GITHUB_TOKEN" ]; then
3939 exit 1
4040fi
4141
42+ # Check for required tools
43+ if ! command -v jq & > /dev/null; then
44+ echo " Error: jq is required but not installed"
45+ exit 1
46+ fi
47+
48+ if ! command -v gh & > /dev/null; then
49+ echo " Error: GitHub CLI (gh) is required but not installed"
50+ exit 1
51+ fi
52+
4253# Log parameter values for debugging (excluding sensitive info)
4354echo " Running issue-fix-mode with parameters:"
4455echo " Issue Number: $ISSUE_NUMBER "
@@ -76,20 +87,65 @@ FIX_BRANCH="${BRANCH_PREFIX:-fix}-issue-${ISSUE_NUMBER}-${DATE}"
7687# Get issue details
7788echo " Fetching issue #$ISSUE_NUMBER details"
7889# Make sure we're using the correct repo format for the gh cli
79- FULL_REPO=" $REPO_OWNER /$REPO_NAME "
90+ # Handle both full repo format (owner/name) and just name format
91+ if [[ " $REPO_NAME " == * " /" * ]]; then
92+ # REPO_NAME already contains owner/name format
93+ FULL_REPO=" $REPO_NAME "
94+ else
95+ # Need to construct owner/name format
96+ FULL_REPO=" $REPO_OWNER /$REPO_NAME "
97+ fi
8098echo " Using repository: $FULL_REPO "
81- ISSUE_DETAILS=$( gh issue view $ISSUE_NUMBER --repo " $FULL_REPO " --json title,body,labels)
99+ if ! ISSUE_DETAILS=$( gh issue view $ISSUE_NUMBER --repo " $FULL_REPO " --json title,body,labels 2> /tmp/gh_issue_error.log) ; then
100+ echo " Error fetching issue details:"
101+ cat /tmp/gh_issue_error.log
102+ exit 1
103+ fi
82104
83- ISSUE_TITLE=$( echo " $ISSUE_DETAILS " | jq -r ' .title' )
84- ISSUE_BODY=$( echo " $ISSUE_DETAILS " | jq -r ' .body' )
85- ISSUE_LABELS=$( echo " $ISSUE_DETAILS " | jq -r ' .labels[].name' | tr ' \n' ' ,' | sed ' s/,$//' )
105+ # Extract data from JSON with error handling
106+ if ! ISSUE_TITLE=$( echo " $ISSUE_DETAILS " | jq -r ' .title' 2> /dev/null) ; then
107+ echo " Error: Failed to extract issue title from JSON response"
108+ echo " JSON response: $ISSUE_DETAILS "
109+ exit 1
110+ fi
111+
112+ if ! ISSUE_BODY=$( echo " $ISSUE_DETAILS " | jq -r ' .body' 2> /dev/null) ; then
113+ echo " Error: Failed to extract issue body from JSON response"
114+ echo " JSON response: $ISSUE_DETAILS "
115+ exit 1
116+ fi
117+
118+ if ! ISSUE_LABELS=$( echo " $ISSUE_DETAILS " | jq -r ' .labels[].name' 2> /dev/null | tr ' \n' ' ,' | sed ' s/,$//' 2> /dev/null) ; then
119+ echo " Warning: Failed to extract issue labels or no labels found"
120+ ISSUE_LABELS=" none"
121+ fi
122+
123+ echo " Successfully extracted issue data: Title='$ISSUE_TITLE ', Labels='$ISSUE_LABELS '"
86124
87125# Get repo information
88126echo " Fetching repository information"
89- REPO_INFO=$( gh repo view " $FULL_REPO " --json name,description,defaultBranchRef,languages)
90- REPO_DESC=$( echo " $REPO_INFO " | jq -r ' .description' )
91- DEFAULT_BRANCH=$( echo " $REPO_INFO " | jq -r ' .defaultBranchRef.name' )
92- REPO_LANGUAGES=$( echo " $REPO_INFO " | jq -r ' .languages[].name' | tr ' \n' ' , ' | sed ' s/,$//' )
127+ # Use same FULL_REPO format from above
128+ echo " Using repository for repo info: $FULL_REPO "
129+ if ! REPO_INFO=$( gh repo view " $FULL_REPO " --json name,description,defaultBranchRef,languages 2> /tmp/gh_repo_error.log) ; then
130+ echo " Error fetching repository information:"
131+ cat /tmp/gh_repo_error.log
132+ exit 1
133+ fi
134+ # Extract repo data with error handling
135+ if ! DEFAULT_BRANCH=$( echo " $REPO_INFO " | jq -r ' .defaultBranchRef.name' 2> /dev/null) ; then
136+ echo " Error: Failed to extract default branch information"
137+ echo " JSON response: $REPO_INFO "
138+ exit 1
139+ fi
140+
141+ REPO_DESC=$( echo " $REPO_INFO " | jq -r ' .description // "No description"' 2> /dev/null)
142+
143+ if ! REPO_LANGUAGES=$( echo " $REPO_INFO " | jq -r ' .languages[].name' 2> /dev/null | tr ' \n' ' , ' | sed ' s/,$//' 2> /dev/null) ; then
144+ echo " Warning: Failed to extract repo languages or no languages found"
145+ REPO_LANGUAGES=" unknown"
146+ fi
147+
148+ echo " Successfully extracted repo data: Default branch='$DEFAULT_BRANCH ', Languages='$REPO_LANGUAGES '"
93149
94150# Create a new branch for the fix
95151echo " Creating a new branch: $FIX_BRANCH "
0 commit comments