Repository navigation
fix(http): getMeta returns no metadata for a missing key - #866
superbot-helper wants to merge 1 commit into
Conversation
The http driver's hasItem, getItem and getItemRaw all catch a failed request
and answer false or null. getMeta did not, so a key that simply does not exist
rejected with FetchError 404 where the siblings answered. `Driver.getMeta` is
typed `StorageMeta | null` and core merges a null, so the exception was never
part of the contract.
Reuses catchFetchError and returns null, which core turns into {} the same way
it does for memory and fs.
|
@superbot-helper is attempting to deploy a commit to the unjs Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
What happens
The http driver's hasItem, getItem and getItemRaw all catch a failed request and answer false or null. getMeta did not, so a key that simply does not exist rejected with an exception where its siblings answered.
Against a real createStorageHandler behind a node server, through the published [email protected]:
Driver.getMeta is typed StorageMeta | null (src/types.ts:132) and core merges a null into an empty object (src/storage.ts:443-446), so throwing was never part of the contract. Any caller that probes metadata before reading — revalidation, a conditional fetch — gets an exception instead of "no metadata".
The change
Reuses catchFetchError, the same helper the three sibling methods one screen above already use, and returns null when there is no response. Core turns that into {} exactly as it does for memory and fs. One call site, no new dependency, no change to any other method.
Verification
Patched build against the published package: getMeta("nope") now answers {}, matching memory. Restoring the unpatched driver file reproduces the 404 exception. Nothing else in the driver changed.
Not a duplicate
Six open pull requests mention getMeta (#772, #587, #363, #276, #807, #859) and none touches the http driver's metadata path; 41 open pull requests mention the http driver and none is this. Searched by symptom across issues and pull requests, open and closed.
Scope
The http driver only. The same 404 tolerance question for the Azure drivers is a separate surface and is not touched here.
Summary by CodeRabbit