mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-23 11:42:21 +00:00
fix(recent-imagery): avoid exposing transport errors
This commit is contained in:
1 parent
6b216b3534
commit
5f1c230b52
3 files changed
+31
-4
No files matched your search
@@ -351,7 +351,7 @@ test('a half that fails or stalls after the other half proved data does not unse
|
||||
const strict = createRecentImagerySource({ fetchImpl: failing.fetchImpl });
|
||||
await assert.rejects(
|
||||
strict.getThumbnail(FIJI_CANDIDATE, FIJI_BOX),
|
||||
/snapshot failed/,
|
||||
/Thumbnail request failed/,
|
||||
'a failed half is an error, never an empty day',
|
||||
);
|
||||
});
|
||||
@@ -683,6 +683,29 @@ test('frozen responses retain availability', async () => {
|
||||
assert.ok((await response.blob()).size);
|
||||
});
|
||||
|
||||
test('transport rejection does not expose untrusted error details', async () => {
|
||||
const marker = 'synthetic-secret-do-not-expose-ABC123';
|
||||
const source = createRecentImagerySource({
|
||||
thumbnailUrl: () => 'https://example.invalid/',
|
||||
fetchImpl: () => {
|
||||
throw new Error(marker);
|
||||
},
|
||||
});
|
||||
await assert.rejects(
|
||||
source.getThumbnail(FIJI_CANDIDATE, FIJI_BOX),
|
||||
(error) => {
|
||||
assert.equal(error.message, 'Thumbnail request failed');
|
||||
assert.equal(
|
||||
`${error.stack} ${JSON.stringify(error)} ${error.cause}`.includes(
|
||||
marker,
|
||||
),
|
||||
false,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test('frozen native Response retains status and text methods', async () => {
|
||||
const source = createRecentImagerySource({
|
||||
thumbnailUrl: () => 'https://example.invalid/',
|
||||
|
||||
@@ -218,8 +218,12 @@ export function createRecentImagerySource({
|
||||
);
|
||||
// A rejected half is an error, never an empty day, unless another half
|
||||
// proved data on its own.
|
||||
if (results.length > responses.length)
|
||||
throw results.find((result) => result.status === 'rejected').reason;
|
||||
if (results.length > responses.length) {
|
||||
const failure = results.find((result) => result.status === 'rejected');
|
||||
if (failure.reason?.name === 'TimeoutError')
|
||||
throw new DOMException('Thumbnail request timed out', 'TimeoutError');
|
||||
throw new Error('Thumbnail request failed');
|
||||
}
|
||||
return withPresentBoxes(combineHalves(responses), []);
|
||||
},
|
||||
getTileTemplate: (product, day) => tileTemplate(product, day),
|
||||
|
||||
@@ -187,6 +187,6 @@ test('a rejected half does not hide data on the other half, and never reads as e
|
||||
});
|
||||
await assert.rejects(
|
||||
failing.source.getThumbnail(candidate, NARROW_WEST),
|
||||
/network/,
|
||||
/Thumbnail request failed/,
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user