Skip to content

Fix VK API error code 10 with retry logic and exponential backoff#29

Open
konard wants to merge 3 commits intomainfrom
issue-15-839ec79a
Open

Fix VK API error code 10 with retry logic and exponential backoff#29
konard wants to merge 3 commits intomainfrom
issue-15-839ec79a

Conversation

@konard
Copy link
Copy Markdown
Owner

@konard konard commented Oct 17, 2025

🎯 Summary

This PR fixes issue #15 by implementing automatic retry logic with exponential backoff to handle VK API error code 10 ("Internal server error: Unknown error, try later").

📋 Issue Reference

Fixes #15

🔍 Problem Analysis

The VK API occasionally returns error code 10, which is an internal server error. According to VK API error schema, this error is defined as:

  • Error Code: 10
  • Name: "api_error_server"
  • Description: "Internal server error"
  • Global: true (can occur across all API methods)

This is a transient server-side error that requires retrying the request.

✨ Implementation Details

Changes to execute.sh:

  1. Retry Logic: Added automatic retry mechanism with up to 3 attempts
  2. Exponential Backoff: Implements progressive delays (2s → 4s → 8s) between retries
  3. Enhanced Error Detection: Uses jq to properly extract error_code field from JSON responses
  4. Informative Feedback: Logs retry attempts to stderr for better debugging
  5. Backward Compatibility: Preserves existing token refresh functionality for authentication errors

Key Features:

  • ✅ Handles error code 10 specifically with retry logic
  • ✅ Exponential backoff to avoid overwhelming the server
  • ✅ Maximum of 3 retry attempts before failing
  • ✅ Clear error messages for debugging
  • ✅ Maintains all existing error handling (token expiration, IP changes, etc.)
  • ✅ Returns appropriate exit codes for success/failure

🧪 Testing

The solution has been validated for:

  • ✅ Bash syntax checking (no errors)
  • ✅ Preserves existing functionality for token-related errors
  • ✅ Proper JSON parsing with jq
  • ✅ Correct retry and backoff timing logic

📚 References


🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: undefined
@konard konard self-assigned this Oct 17, 2025
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 <noreply@anthropic.com>
@konard konard changed the title [WIP] Unknown error, try later at handle-requests.sh Fix VK API error code 10 with retry logic and exponential backoff Oct 17, 2025
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard marked this pull request as ready for review October 17, 2025 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unknown error, try later at handle-requests.sh

1 participant