Repository navigation
Description
Summary
translateToHttpUrl maps an s3://<bucket>/<key> virtual-chunk location whose bucket name contains a dot to the path-style global endpoint https://s3.amazonaws.com/<bucket>/<key>. For a bucket that lives outside us-east-1, the global endpoint answers 301 Moved Permanently (redirecting to the regional host). The virtual-chunk fetch treats any non-200/206 response as a hard error and does not follow the redirect, so every virtual chunk read fails.
(Split out from #24 as requested there.)
Where
translateToHttpUrl ([email protected]):
if (bucket.includes(".")) {
return `https://s3.amazonaws.com/${bucket}/${key}`; // path-style, global endpoint
}
return `https://${bucket}.s3.amazonaws.com/${key}`; // virtual-hostedDotted bucket names can't use virtual-hosted style over TLS (cert mismatch), so the path-style branch is correct — but it hardcodes the global s3.amazonaws.com host, which 301s for non-us-east-1 buckets.
And in the virtual fetch (makeUrlStore / getRange):
if (response.status !== 200 && response.status !== 206) {
throw new Error(`Failed to fetch virtual chunk from ${url}: ${response.status} ${response.statusText}`);
}→ the 301 is thrown rather than followed.
Reproduction
Public store with virtual refs into a dotted, us-west-2 bucket (s3://us-west-2.opendata.source.coop/…):
https://data.source.coop/tge-labs/meta-chm-v2/zarr/chm.zarr.icechunk
import { HttpStorage, Repository, IcechunkStore } from "icechunk-js";
import * as zarr from "zarrita";
const url = "https://data.source.coop/tge-labs/meta-chm-v2/zarr/chm.zarr.icechunk";
const repo = await Repository.open({ storage: new HttpStorage(url) });
const session = await repo.checkoutBranch("main");
const ice = await IcechunkStore.open(session, { withRangeCoalescing: zarr.withRangeCoalescing });
const group = await zarr.open.v3(ice, { kind: "group" });
const a = await zarr.open.v3(group.resolve("64x/chm"), { kind: "array" });
await zarr.get(a, [zarr.slice(0, 512), zarr.slice(0, 512)]); // a populated region
// → Error: Failed to fetch virtual chunk from
// https://s3.amazonaws.com/us-west-2.opendata.source.coop/.../chm/2101003131.tif: 301 Moved PermanentlyVerified endpoint behavior for that object (range request bytes=0-100):
| URL | Result |
|---|---|
https://s3.amazonaws.com/us-west-2.opendata.source.coop/… (what icechunk builds) |
301 (x-amz-bucket-region: us-west-2) |
https://s3.us-west-2.amazonaws.com/us-west-2.opendata.source.coop/… (regional path-style) |
206 ✓ |
https://data.source.coop/… (public CORS proxy) |
206 ✓ |
Suggested fixes (any one)
- Follow redirects on the virtual fetch — let
fetchfollow the 301 (defaultredirect: "follow") and accept the final 200/206, instead of throwing on the 301 status. Simplest and fixes the general case. - Use the regional path-style endpoint for dotted buckets when the region is known —
https://s3.<region>.amazonaws.com/<bucket>/<key>. Region could come from a virtual-chunk-container config / repo config option. - Document the
fetchClienthook as the supported workaround for custom endpoint/CORS routing (we use it to rewrite onto a CORS proxy).
Workaround in use
A custom fetchClient that rewrites the path-style URL onto a CORS-enabled host:
const ice = await IcechunkStore.open(session, {
withRangeCoalescing: zarr.withRangeCoalescing,
fetchClient: {
fetch: (u, init) => fetch(
u.replace(
/^https:\/\/s3(?:[.-][a-z0-9-]+)?\.amazonaws\.com\/[a-z0-9-]+\.opendata\.source\.coop\//,
"https://data.source.coop/",
),
init,
),
},
});
Activity
Resolve virtual-chunk S3 endpoints from container config (#27)
tylere commentedon Jun 24, 2026
Verified fixed in 0.6.0 🎉 —
regionalS3RedirectUrlnow retries a 301/307 (withx-amz-bucket-region) againsthttps://s3.<region>.amazonaws.com/<bucket>/<key>, and that regional endpoint serves the objects withAccess-Control-Allow-Origin: *, so it works in the browser too. Reading the store without any customfetchClientnow succeeds. Thanks! Leaving open for a maintainer to close.