hackgvl / events-api

API for Greenville Tech Calendar events
MIT License
12 stars 6 forks source link

Sudden Break in the Production API #53

Closed allella closed 2 years ago

allella commented 2 years ago

@ramonaspence late last night the script on the production server started returning an error.

I haven't dug into it a lot yet.

I though perhaps Meetup had changed / deprecated their REST API, since their API docs now list GraphQL, but I can still manually pull up the events URL

https://api.meetup.com/Code-for-Greenville/events?&sign=true&photo-host=public&status=upcoming,cancelled,past&page=50

Could you test it on your local system and see if it's breaking there too?

allella commented 2 years ago

Possibly related

February 10, 2022

Removal of event data feeds

Meetup will no longer support group events data feeds in the following output formats: ATOM, JSON & CSV. We will continue to support the RSS event feed. If you are using ATOM, JSON or CSV feeds, please migrate to the RSS feed for your group.

allella commented 2 years ago

Actually, this break may be in Evenbrite.

I commented out the Eventbrite function locally and the Meetup function seems to work. When I isolated it to only run the Eventbrite stuff, it breaks with the same error as on production.

    raise TypeError('Object of type %s is not JSON serializable' %
TypeError: Object of type module is not JSON serializable
ramonaspence commented 2 years ago

Okay, I've got the same TypeError locally. I'll look into it and edit this comment with more info.

...

The issue seems to be the UUID field in this event object:

{'event_name': '#631 Tech After Five - Charlotte (In Person)', 'group_name': 'Tech After Five', 'venue':   
{'name': 'Hickory Tavern', 'address': '9010 Harris Corners Parkway, ', 'city': 'Charlotte', 'state': None, 'zip': '28269', 'country': 'US', 'lat': '35.3449201', 'lon': '-80.8421901'}, 
'url': 'https://www.eventbrite.com/e/631-tech-after-five-charlotte-in-person-tickets-327548736087', 'time': '2022-05-10T21:30:00Z', 'tags': '', 'rsvp_count': None, 'created_at': '2022-04-25T19:45:59Z', 'description': 'Join us for the gold standard of in person networking for the tech community.', 
'uuid': <module 'uuid' from '/Users/admin/miniconda3/lib/python3.6/uuid.py'>, 'nid': '31', 'data_as_of': '2022-04-26T23:18:34Z', 'status': 'upcoming'}

(I do not know why this code block isn't going to multiple lines but I at least made it where you can see the UUID field) The event is coming from Eventbrite and you can see the value for uuid is a module.

I'm still working out why and how to fix it though.

ramonaspence commented 2 years ago

@allella

Okay got it.

In format_eventbrite_events the uuid field for the venues list is just pointing to "uuid", like this:

if type(event.get('venue_id')) == str:
                event_dict = {
                    'event_name': event.get('name').get('text'),
                    'group_name': group_name,
                    'venue': venues[event.get('venue_id')],
                    'url': event.get('url'),
                    'time': event.get('start').get("utc"),
                    'tags': tags,
                    'rsvp_count': None,
                    'created_at': event.get('created'),
                    'description': event.get('description').get('text'),
                    'uuid': uuid,
                    'nid': nid,
                    'data_as_of': datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ'),
                    'status': normalize_eventbrite_status_codes(event.get('status'))
                }

It's possible that we are encountering an in-person meeting, and thus one that has a venue object, for the first time since that change was made. Changing the line so that 'uuid' is set to a unique_id defined before it, gets rid of the error.

I'll spin up a branch for this change and test it tomorrow evening.

allella commented 2 years ago

Great. Thanks. I've temporarily disabled the Eventbrite function on production, so it's mostly not breaking things.

I may need to check the meetups using Eventbrite on the Hackgreenville site because it tries to cache and save events, so I'm wondering if this change will cause some HG events to show as cancelled and/or duplicate due to the way that site works.