Skip to content

Fix missing return in _retryer that propagated None tiles#282

Open
madhavcodez wants to merge 1 commit into
geopandas:mainfrom
madhavcodez:fix/retryer-none-tile-252
Open

Fix missing return in _retryer that propagated None tiles#282
madhavcodez wants to merge 1 commit into
geopandas:mainfrom
madhavcodez:fix/retryer-none-tile-252

Conversation

@madhavcodez

Copy link
Copy Markdown

Root cause

_retryer retries on non-404 failures, but the retry branch never returned the recursive call's result:

request = _retryer(tile_url, wait, max_retries, headers, timeout=timeout)

After kicking off the retry, the function fell through and implicitly returned None. That None was collected as a tile "array" and later reached _merge_tiles, where h, w, d = arrays[0].shape raised AttributeError: 'NoneType' object has no attribute 'shape' (or a TypeError on the array assignment when the None was not in first position). This is why #252 was intermittent: it only surfaced when a tile hit a non-404 error and then succeeded on retry. The earlier np.asarray(None) theory in the thread was not the cause.

Fix

  • Return the recursive call in _retryer (request = _retryer(...) becomes return _retryer(...)). This is the actual fix.
  • Defense in depth: _merge_tiles now raises a clear ValueError if any tile array is None, instead of failing with an obscure AttributeError/TypeError further down.

Tests

Three network-free tests added: _merge_tiles raises the clear ValueError for a missing tile in both first and later positions; _retryer returns the array (not None) after a non-404 failure followed by a successful retry; and _retryer raises (rather than returning None) when retries are exhausted. They pass with the fix and fail without it. pytest -m "not network" reports 14 passed.

The second change (the _merge_tiles guard) is defense in depth and not required to fix #252. Happy to drop it if you would prefer the root-cause change only.

Closes #252

_retryer retries on non-404 failures, but the retry branch ran
    request = _retryer(...)
without returning the result, so the function fell through and implicitly
returned None. That None was collected as a tile array and later crashed
_merge_tiles at "h, w, d = arrays[0].shape" (AttributeError) or at the array
assignment (TypeError), which is the intermittent failure reported in geopandas#252.

Return the recursive call. As defense-in-depth, _merge_tiles now raises a clear
ValueError if any tile array is None instead of failing with an obscure
AttributeError/TypeError further down.

Add network-free tests: _merge_tiles raises the clear ValueError for a missing
tile in first and later positions; _retryer returns the array after a non-404
failure then a successful retry; and _retryer raises (not returns None) when
retries are exhausted.

Closes geopandas#252
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.

catch image=None in _retryer()

1 participant