Repository navigation
fix(geotiff): Turn off HTTP request bounds checking - #527
Merged
Merged
Conversation
…en't rejected `@chunkd/source-http` records `source.metadata.size` from the first range response, preferring `Content-Range` and falling back to `Content-Length`. In a browser, `Content-Range` is only readable when the server lists it in `Access-Control-Expose-Headers` (S3 does not by default), so the `Content-Length` fallback — the length of a single chunk, not the file — gets recorded as the file size. `@chunkd/middleware`'s chunk layer then rejects any later read past that bogus size with "SourceError: Request outside of bounds". This broke the land-cover example on load: its huge tile-offset arrays push the IFD section past 1 MB, so even the coarsest overview's tile data lives past the first chunk. Seed `metadata` in `GeoTIFF.fromUrl` so `SourceHttp` never records a size (it only fills in `metadata` while it is still null), treating the source as having unbounded length. Temporary until the upstream fix lands. Closes #524 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
kylebarron
enabled auto-merge (squash)
May 11, 2026 21:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #524.
cc @gadomski
Problem
The land-cover example fails on
mainwithSourceError: Request outside of bounds(#524).@chunkd/source-httpderivessource.metadata.sizefrom the first range response, preferringContent-Rangeand falling back toContent-Length. In a browser,Content-Rangeis only readable when the server lists it inAccess-Control-Expose-Headers— S3 does not by default — so theContent-Lengthfallback (the length of a single chunk, not the file) gets recorded as the file size.@chunkd/middleware's chunk layer then rejects any later read whose end is past that bogus size withSourceError: Request outside of bounds— which is exactly the leader-byte readTiffImage.getTileSizeperforms.Why land-cover specifically? The NLCD COG is 160000×105000 px → ~64K full-res tiles, so its
TileOffsets/TileByteCountsarrays alone are ~1 MB and push the whole IFD/tag section past the 1 MB mark. So even the coarsest overview's tile data lives past the first chunk, and the layer breaks on initial load. Other examples have small headers, so the data deck.gl reads at the initial coarse zoom is within the first chunk — they'd hit the same bug fully zoomed in (cf. developmentseed/stac-map#459), it's just less obvious.Fix
Seed
source.metadatainGeoTIFF.fromUrlsoSourceHttpnever records a size (it only fills inmetadatawhile it's stillnull), treating the source as having unbounded length. This makes@chunkd/middleware's bounds check a no-op and stops cogeotiff'sgetMaxLengthfrom clamping — i.e. it behaves like@chunkd/middlewaredid before the bounds check was added. No dependency changes, no extra round-trip.Trade-offs: we lose
@chunkd/source-http's ETag-changed-mid-read detection and the legit "don't read past EOF" guard — both edge cases, acceptable for a temporary patch. TODO: remove once the upstream@chunkdfix lands.Tests
New regression test (
packages/geotiff/tests/fromurl.test.ts) stubsSourceHttp.fetchto mimic S3-as-seen-from-a-browser (range GETs reportContent-Lengthbut noContent-Range), opens a fixture COG viaGeoTIFF.fromUrl({ chunkSize: 1024 }), and asserts a header-source read near EOF doesn't throw. Confirmed red (Request outside of boundsfromSourceChunk.fetch) → green.pnpm --filter @developmentseed/geotiff test,... typecheck,pnpm check, and thedeck.gl-geotiffsuite all pass. (The 17integration-rasteriofailures present on this branch are pre-existing — missing local.npyfixtures — and unrelated.)🤖 Generated with Claude Code