Skip to content

Fix #48, #54 by surfacing likely API error conditions to the logs#71

Merged
robz merged 1 commit into
asmbly-makerspace:mainfrom
epowell:epowell/type-errors
Mar 16, 2026
Merged

Fix #48, #54 by surfacing likely API error conditions to the logs#71
robz merged 1 commit into
asmbly-makerspace:mainfrom
epowell:epowell/type-errors

Conversation

@epowell
Copy link
Copy Markdown
Contributor

@epowell epowell commented Feb 6, 2026

Fix for GitHub Issues #48 and #54

Problem Summary

Both issues reported the same error in dailyClassChecker.py and classFeedbackAutomation.py:

TypeError: list indices must be integers or slices, not str

Occurring at line:

RESPONSE_EVENTS = neon.postEventSearch(SEARCH_FIELDS, OUTPUT_FIELDS)["searchResults"]

Root Cause

According to the Neon CRM API documentation, the /events/search endpoint should always return:

{
  "searchResults": [...],
  "pagination": {...}
}

However, when the API encounters certain error conditions (rate limiting, validation errors, etc.), it may return HTTP 200 with an error response in a different format, such as:

  • An empty list: []
  • An error list: [{"errorMessage": "..."}]

When the response.json() call parses these error responses, they become Python lists. Then trying to access ["searchResults"] on a list fails with the exact error observed.

The Fix

Modified three functions in helpers/neon.py to add proper error handling:

  1. postEventSearch() (line 103)
  2. postOrderSearch() (line 197)
  3. postAccountSearch() (line 259)

Each function now:

  1. ✅ Checks the HTTP status code before parsing JSON
  2. ✅ Validates that the response is a dictionary (not a list)
  3. ✅ Validates that the dictionary contains the expected searchResults key
  4. ✅ Raises a descriptive ValueError with the actual response content if validation fails

@robz robz merged commit 357a03d into asmbly-makerspace:main Mar 16, 2026
1 check passed
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.

2 participants