Common Errors
Authentication Errors
401 Unauthorized
Error message:-
Verify your access token is correctly set in
events.js:2: -
Check that the token hasn’t expired. Generate a new token if needed:
- Go to HubSpot Settings → Integrations → Private Apps
- Create a new token or regenerate an existing one
-
Ensure the token has the required scopes:
crm.objects.deals.readcrm.objects.deals.writecrm.schemas.deals.readmarketing-events.read
403 Forbidden
Error message:-
Update your Private App scopes to include:
- Marketing Events API read access
- CRM Objects (Deals) read/write access
- After updating scopes, the token may be regenerated automatically. Update your script with the new token.
Validation Errors
VALIDATION_ERROR: Duplicate Record
Error from console (events.js:309-312):
dealname already exists, and HubSpot’s unique property constraint is violated.
How the script handles it:
The script includes duplicate detection (events.js:154-180 and events.js:339-344):
-
Review skipped events in the output:
- If you need to update existing records instead of skipping them, modify the script to use a PATCH request instead.
Invalid Property Values
Error:organizador_evento property received a value not in HubSpot’s allowed options.
Solution:
The script maps organizers to valid values (events.js:230-266). Update the mapping to include your organizers:
- Go to HubSpot Settings → Properties → Deal Properties
- Find the
organizador_eventoproperty - Note the exact values in the “Options” list
- Update the return values in the mapping function to match exactly
Field Name Note: The code references
eventData.hs_event_organizer (events.js:280), but the HubSpot Marketing Events API returns this field as eventOrganizer (see test.js:11,35,58). This inconsistency means the organizer mapping may not work as expected with real API data. If you encounter issues with organizer values, verify the actual field name in your API responses and update line 280 accordingly.Rate Limiting
429 Too Many Requests
Error:- 100 requests per 10 seconds (default)
- Varies by subscription tier
-
Reduce batch size: The script processes 100 events per page (
events.js:12). Consider reducing: -
Add delays between requests: Insert a delay between API calls:
-
Implement exponential backoff:
Date Parsing Issues
Events Not Filtered Correctly
Symptom: Events from previous days are being processed, or today’s events are being skipped. Cause: Date parsing issues in thefindHsCreatedate function (events.js:54-99).
Debug steps:
-
Add logging to see what dates are being parsed:
-
Check timezone issues: The script uses local time (
events.js:45-46):If your HubSpot events use UTC timestamps, you may need to adjust: -
Verify date format: Check that
hs_createdateis in milliseconds or ISO format:
Network and Connection Errors
ECONNREFUSED / ETIMEDOUT
Error:- Check your internet connection
- Verify that
api.hubapi.comis accessible: - Check proxy settings if behind a corporate firewall
- Ensure Node.js can make HTTPS requests
Fetch is not defined
Error:node-fetch.
Solution:
-
Upgrade to Node.js 18+ (recommended):
-
Or install node-fetch:
Then update
events.js:
Reading Error Logs
Console Log Structure
The script uses specific emoji prefixes to categorize log messages:Error Context
Errors include context to help identify the source: API fetch error (events.js:24-28):
events.js:309):
events.js:354-356):
Final Output
The callback includes a comprehensive summary (events.js:362-384):
createdCount: Successfully created dealsskippedCount: Events that already exist (not an error)failedCount: Events that encountered errors (investigatefailedEvents)
Debugging Tips
Enable Verbose Logging
Add detailed logging to track execution:Capture Full API Responses
Log the complete response before parsing:Test Individual Functions
Isolate and test specific functions:Use the Test Script
Runtest.js to validate logic without API calls:
mockEventsResponse to reproduce specific scenarios.
Check HubSpot API Status
If experiencing widespread issues:- Check HubSpot’s status page: status.hubspot.com
- Review HubSpot’s API changelog for recent changes
- Test API endpoints directly with
curl:
Getting Help
If you’re still experiencing issues:-
Collect diagnostic information:
- Node.js version (
node --version) - Full error message and stack trace
- Sample event data (redact sensitive info)
- Console output from test script
- Node.js version (
-
Review the source code:
events.js:7-40- Event fetching logicevents.js:54-123- Date filteringevents.js:126-180- Duplicate detectionevents.js:269-319- Record creation
- Contact support with the diagnostic information
Next Steps
Local Setup
Return to local setup instructions
Testing
Review testing procedures