From 60c5b5e57c7d979183684a427fba82636a55658f Mon Sep 17 00:00:00 2001 From: konard Date: Fri, 17 Oct 2025 19:14:04 +0300 Subject: [PATCH 1/3] Initial commit with task details for issue #15 Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: undefined --- CLAUDE.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..2c1fe45 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,5 @@ +Issue to solve: undefined +Your prepared branch: issue-15-839ec79a +Your prepared working directory: /tmp/gh-issue-solver-1760717642560 + +Proceed. \ No newline at end of file From a8eb368664156299f36e22546502b104f552847f Mon Sep 17 00:00:00 2001 From: konard Date: Fri, 17 Oct 2025 19:16:47 +0300 Subject: [PATCH 2/3] Add retry logic with exponential backoff for VK API error code 10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit addresses issue #15 where the VK API returns error code 10 ("Internal server error: Unknown error, try later"). Key changes: - Implemented retry logic with up to 3 attempts for error code 10 - Added exponential backoff (2s, 4s, 8s) between retries - Enhanced error detection using jq to extract error_code field - Maintains existing token refresh functionality for auth errors - Provides informative feedback during retry attempts The solution handles transient VK API server errors gracefully by automatically retrying the request with increasing delays, which is the recommended approach for this type of error according to VK API documentation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- execute.sh | 64 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 12 deletions(-) diff --git a/execute.sh b/execute.sh index e72657b..18929bd 100755 --- a/execute.sh +++ b/execute.sh @@ -3,19 +3,59 @@ TOKEN_EXPIRED_ERROR_MESSAGE="User authorization failed: access_token has expired." TOKEN_WAS_GIVEN_TO_ANOTHER_IP_ERROR_MESSAGE="User authorization failed: access_token was given to another ip address." NO_TOKEN_PASSED_ERROR_MESSAGE="User authorization failed: no access_token passed." +INTERNAL_SERVER_ERROR_MESSAGE="Internal server error: Unknown error, try later" -QUERY_RESULT=$(curl -s "$1") +# Retry configuration +MAX_RETRIES=3 +RETRY_DELAY=2 -ERROR_MESSAGE=$(echo "$QUERY_RESULT" | jq .error.error_msg | tr -d '"') +# Function to execute API call with retry logic +execute_with_retry() { + local url="$1" + local attempt=1 -echo "$QUERY_RESULT" | jq + while [ $attempt -le $MAX_RETRIES ]; do + QUERY_RESULT=$(curl -s "$url") + ERROR_CODE=$(echo "$QUERY_RESULT" | jq -r '.error.error_code // empty') + ERROR_MESSAGE=$(echo "$QUERY_RESULT" | jq -r '.error.error_msg // empty') -if [ "$ERROR_MESSAGE" = "$TOKEN_EXPIRED_ERROR_MESSAGE" ] || [ "$ERROR_MESSAGE" = "$TOKEN_WAS_GIVEN_TO_ANOTHER_IP_ERROR_MESSAGE" ] || [ "$ERROR_MESSAGE" = "$NO_TOKEN_PASSED_ERROR_MESSAGE" ]; then - # Get new access token - EMAIL=`cat email` - PASS=`cat pass` - cat vk_auth_token.side | jq '.tests[0].commands[2].value="'"$EMAIL"'" | .tests[0].commands[4].value="'"$PASS"'"' > vk_auth_token.temp - selenium-side-runner vk_auth_token.temp | grep -o "https.*" | sed -r "s|.*access_token=([^&]+)&.*|\1|" > access-token - rm vk_auth_token.temp - echo "Token is updated" -fi; \ No newline at end of file + # Check if the request was successful (no error field) + if [ -z "$ERROR_CODE" ]; then + echo "$QUERY_RESULT" | jq + return 0 + fi + + # Check for error code 10 (Internal server error) + if [ "$ERROR_CODE" = "10" ]; then + if [ $attempt -lt $MAX_RETRIES ]; then + echo "Internal server error detected (attempt $attempt/$MAX_RETRIES). Retrying in ${RETRY_DELAY}s..." >&2 + sleep $RETRY_DELAY + # Exponential backoff + RETRY_DELAY=$((RETRY_DELAY * 2)) + attempt=$((attempt + 1)) + continue + else + echo "Max retries reached. VK API is still returning internal server error." >&2 + echo "$QUERY_RESULT" | jq + return 1 + fi + fi + + # For other errors, break the loop and handle below + echo "$QUERY_RESULT" | jq + break + done + + # Handle token-related errors + if [ "$ERROR_MESSAGE" = "$TOKEN_EXPIRED_ERROR_MESSAGE" ] || [ "$ERROR_MESSAGE" = "$TOKEN_WAS_GIVEN_TO_ANOTHER_IP_ERROR_MESSAGE" ] || [ "$ERROR_MESSAGE" = "$NO_TOKEN_PASSED_ERROR_MESSAGE" ]; then + # Get new access token + EMAIL=`cat email` + PASS=`cat pass` + cat vk_auth_token.side | jq '.tests[0].commands[2].value="'"$EMAIL"'" | .tests[0].commands[4].value="'"$PASS"'"' > vk_auth_token.temp + selenium-side-runner vk_auth_token.temp | grep -o "https.*" | sed -r "s|.*access_token=([^&]+)&.*|\1|" > access-token + rm vk_auth_token.temp + echo "Token is updated" + fi +} + +execute_with_retry "$1" \ No newline at end of file From 3a1c59741e5f862d5e9fa9dc0dc78ae7e36aa680 Mon Sep 17 00:00:00 2001 From: konard Date: Fri, 17 Oct 2025 19:18:16 +0300 Subject: [PATCH 3/3] Remove CLAUDE.md file (not needed for solution) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- CLAUDE.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index 2c1fe45..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,5 +0,0 @@ -Issue to solve: undefined -Your prepared branch: issue-15-839ec79a -Your prepared working directory: /tmp/gh-issue-solver-1760717642560 - -Proceed. \ No newline at end of file