Skip to content

Conversation

@justin-outdoorithm
Copy link

Summary

Fixes #377 - GoingToCamp provider raises KeyError when calling find_campgrounds() for any recreation area.

Root Cause

The CAMP_DETAILS API returns regional map data where all entries have resourceLocationId=None, causing the campground_details dictionary to only contain {None: <last_entry>}. When _process_facilities_responses tries to look up the actual facility's resource_location_id, it raises a KeyError.

The Fix

The LIST_CAMPGROUNDS API response already contains rootMapId for each facility. This fix uses that value directly instead of the broken CAMP_DETAILS lookup.

Changes:

  • Add root_map_id field to ResourceLocation class in gtc_api_responses.py
  • Capture rootMapId from LIST_CAMPGROUNDS in _filter_facilities_responses()
  • Use facility.root_map_id directly in _process_facilities_responses()
  • Remove unused CAMP_DETAILS API call and campground_details dictionary

Testing

Tested locally against all affected recreation areas:

  • Washington State Parks (rec_area_id=3) - 78 campgrounds ✓
  • Wisconsin State Parks (rec_area_id=7) - 50 campgrounds ✓
  • BC Parks (rec_area_id=1) - 110 campgrounds ✓
  • Parks Canada (rec_area_id=2) - 76 campgrounds ✓

Before (crashes)

provider = GoingToCamp()
campgrounds = provider.find_campgrounds(rec_area_id=[3])
# KeyError: -2147483647

After (works)

provider = GoingToCamp()
campgrounds = provider.find_campgrounds(rec_area_id=[3])
# Returns 78 campgrounds for Washington State Parks

The CAMP_DETAILS API returns regional map data where all entries have
resourceLocationId=None, causing the campground_details dictionary to
only contain {None: <last_entry>}. When _process_facilities_responses
tries to look up the actual facility's resource_location_id, it raises
a KeyError.

This fix uses the rootMapId field that's already present in the
LIST_CAMPGROUNDS API response instead of the broken CAMP_DETAILS lookup.

Changes:
- Add root_map_id field to ResourceLocation class
- Capture rootMapId from LIST_CAMPGROUNDS in _filter_facilities_responses
- Use facility.root_map_id directly in _process_facilities_responses
- Remove unused CAMP_DETAILS API call and campground_details dictionary

Fixes juftin#377
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.

[BUG] GoingToCamp provider KeyError when listing campgrounds

1 participant