Skip to content

Conversation

@konard
Copy link
Owner

@konard konard commented Sep 22, 2025

Summary

  • Replace raw ENOENT errors with helpful, human-readable messages for missing token files
  • Add specific guidance on how to create and configure the token file
  • Improve error handling across all file reading operations in the codebase
  • Add comprehensive error handling for JSON parsing failures

Changes Made

  • utils.js: Enhanced getToken() with detailed error message including setup instructions and VK API documentation link
  • utils.js: Improved readTextSync() and readJsonSync() with better error messages for missing files and invalid JSON
  • filter-stickers.js: Added error handling for missing/invalid received-attachments.json
  • convert-messages-to-markdown.js: Added JSON parsing error handling
  • triggers/attachments.js: Added graceful error handling that allows continuation with empty state

Before (Issue #33)

Error: ENOENT: no such file or directory, open 'token'
    at Object.openSync (node:fs:601:3)
    at Object.readFileSync (node:fs:469:35)

After

Error: Token file "token" not found. Please create a file named "token" containing either:
  1. Your VK API access token (a string of characters)
  2. A VK OAuth URL with access_token parameter

For more information on how to get a VK API token, visit: https://vk.com/dev/access_token

Test Plan

  • Verified all scripts using getToken() show improved error messages
  • Tested file reading functions with missing files
  • Tested JSON parsing with invalid JSON files
  • Created comprehensive test suite in experiments/ folder
  • Confirmed existing functionality works with valid token files

🤖 Generated with Claude Code

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

Issue: #33
@konard konard self-assigned this Sep 22, 2025
Replace raw ENOENT errors with helpful messages that guide users on how to:
- Create the token file
- Understand what content should be in it
- Get help with VK API token acquisition

Improved error handling across all file reading operations:
- getToken() now shows specific guidance for token file creation
- readTextSync() and readJsonSync() show clear file not found messages
- JSON parsing errors now indicate syntax issues
- Scripts using direct fs.readFileSync updated with better error handling

Fixes #33

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

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Error: ENOENT: no such file or directory, open 'token' Add human-readable error messages for missing token file Sep 22, 2025
@konard konard marked this pull request as ready for review September 22, 2025 20:27
@konard
Copy link
Owner Author

konard commented Sep 22, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

📎 Log file uploaded as GitHub Gist (200KB)
🔗 View complete solution draft log


Log automatically attached by solve.mjs with --attach-logs option

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.

1 participant