Skip to content

Conversation

@konard
Copy link
Owner

@konard konard commented Oct 17, 2025

Summary

This PR adds proper error handling for VK API error code 5 (User authorization failed) in the delete-outgoing-requests trigger.

Problem

Issue #28 reported an unhandled error when running delete-outgoing-requests.js:

APIError: Code №5 - User authorization failed: user is blocked.

The error occurred when calling friends.getRequests API method, causing the script to crash instead of gracefully handling the authorization failure.

Solution

Added a try-catch block specifically for the friends.getRequests API call to:

  • Catch VK API error code 5 (User authorization failed)
  • Log a descriptive error message explaining the issue
  • Gracefully exit instead of crashing

This follows the error handling pattern used in the accept-friend-requests trigger for handling similar VK API errors.

Changes

  • Modified triggers/delete-outgoing-requests.js to add error code 5 handling
  • When error code 5 is detected, logs: "Could not get outgoing friend requests: User authorization failed. The account may be blocked or the access token is invalid."
  • Other errors are re-thrown to be caught by the outer try-catch block

Testing

  • Reviewed existing error handling patterns in accept-friend-requests trigger
  • Ran npm test to ensure no regressions (existing test failures are unrelated to this change)
  • Verified the change follows the repository's error handling conventions

Fixes #28

🤖 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 adds proper error handling for VK API error code 5 (User
authorization failed) when attempting to get outgoing friend requests.

When the user account is blocked or the access token is invalid, the
function now catches the error, logs a descriptive message, and
gracefully exits instead of crashing.

This follows the error handling pattern used in accept-friend-requests
trigger and ensures the bot can handle authorization failures gracefully.

Fixes #28

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] APIError: Code №5 - User authorization failed: user is blocked. Add error handling for VK API error code 5 Oct 17, 2025
@konard konard marked this pull request as ready for review October 17, 2025 17:28
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.

APIError: Code №5 - User authorization failed: user is blocked.

1 participant