Bug: fetch.py swallows ALL exceptions silently — impossible to debug OSM fetch failures

Author: ardjo-sCreated Aug 21, 2026Updated Aug 21, 2026

Bug: fetch.py swallows ALL exceptions silently — impossible to debug OSM fetch failures

Describe the bug

fetch.py has two bare except Exception as e: blocks that catch and discard every error. When Overpass returns a 429, a timeout, a malformed JSON, or a partial payload, the error is completely swallowed. The user sees Fetching geodataframes took 120s followed by a downstream KeyError with no indication that the actual problem was an Overpass rate-limit.

To reproduce

python
import prettymaps
prettymaps.plot("Zurich, Switzerland", radius=1800)
# → Fetching geodataframes took 128.19 seconds
# → KeyError: 'highway'   ← no indication that Overpass returned empty/partial data

Expected behavior

Errors during OSM data fetching should be logged or surfaced so the user can understand why a render failed and take action (retry, use a different Overpass endpoint, reduce radius, etc.).

Root cause

Line 609unified_osm_request main fetch:

python
try:
    all_features = ox.features.features_from_polygon(bbox, tags=combined_tags)
except Exception as e:
    all_features = GeoDataFrame(geometry=[])   # silently empty, no log

Line 692 — per-layer split:

python
except Exception as e:
    # print(f"Error fetching {layer}: {e}")    ← commented out!
    gdfs[layer] = GeoDataFrame(geometry=[])

Suggested fix

  1. Uncomment the print/log line, or use the logging module:
python
except Exception as e:
    logging.warning(f"Error fetching layer '{layer}': {e}")
  1. Distinguish recoverable errors (empty result) from fatal ones (auth, network):
python
except (ConnectionError, TimeoutError) as e:
    raise RuntimeError(f"Overpass API unreachable: {e}") from e
except Exception as e:
    logging.warning(f"Layer '{layer}' fetch failed: {e}")
  1. Surface Overpass 429 responses with a retry hint and User-Agent header guidance.

Environment

  • prettymaps v1.4.2
  • Python 3.10.18 (Homebrew)
  • osmnx 1.2.2
  • macOS 15, ARM64

Source: marceloprates/prettymaps