Fix ESRIGeoJSON: handle Empty reply from server and paginate past maxRecordCount - #52
Conversation
9d511cb to
2e53ff1
Compare
GDAL's curl-based fetcher fails with "Empty reply from server" against some ArcGIS endpoints (e.g. Cloudflare-fronted servers that only offer HTTPS 1.1). Fetch remote URLs with Ruby's open-uri and hand ogr2ogr a local tempfile instead. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ArcGIS query endpoints truncate each response at the service's maxRecordCount (commonly 1000 or 2000 features) and set exceededTransferLimit when more results exist. Walk the pages with resultOffset and merge them into a single FeatureCollection before handing to ogr2ogr. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
a478c9f to
454e3e7
Compare
`ESRIGeoJSON` walks an ArcGIS query endpoint's pages until one comes back without `exceededTransferLimit`. A server that does not honour `resultOffset` answers every request with the same first page and that flag still set, so the walk never reaches a last page and the collection grows until the process runs out of memory. The walk now stops after `max_pages` requests and raises, rather than writing a collection that is missing whatever came after the cap. A page that does not parse as JSON, and an endpoint that cannot be reached at all, both raise `ImportError` naming what happened instead of surfacing `JSON::ParserError` or `OpenURI::HTTPError`. Each request is bounded by `request_timeout`, since a hung endpoint would otherwise hold an import worker open indefinitely. `max_pages` and `request_timeout` are `class_attribute`s, defaulting to 500 and 60 seconds, which a deployment with a larger layer or a slower service can raise. Adds the importer's first specs, covering a single page, a walk across several pages, the `resultOffset` each request asks for, the flag nested under `properties`, a runaway server, an unparseable reply, an unreachable one, the request timeout, a local path read without downloading, and a local path holding shell metacharacters. Both response shapes are exercised: the GeoJSON an `f=geojson` query returns and the ESRI JSON an `f=json` query returns, the latter being the format the class is named for and the one OGR has to sniff from the content. They stub `URI` the way `kml_file_arcgis_spec.rb` stubs `Download`, so no new test dependency. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Both points addressed, and acting on them turned up two defects that were not visible before.
|
454e3e7 to
232983b
Compare
Summary
ESRIGeoJSONpassed remote URLs straight toogr2ogr, which uses GDAL's curl client. Some ArcGIS-on-IIS endpoints return an empty reply to that client (likely an HTTPS 1.1 negotiation issue — GDAL's driver list hints at this withMapInfo File' needs https 1.1), producingERROR 1: Empty reply from server. Fix: fetch the URL with Ruby's `open-uri` into a tempfile, then run `ogr2ogr` on the local path.Test plan
🤖 Generated with Claude Code