-
Notifications
You must be signed in to change notification settings - Fork 10
Harden imported artifact remote page fallback #1231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -145,6 +145,7 @@ async function fetchFirstAvailableAssertionArtifact( | |
| resolved: AssertionArtifactResolution, | ||
| opts: { | ||
| sourcePeerIds: string[]; | ||
| explicitSourcePeerId?: boolean; | ||
| offset: number; | ||
| maxBytes: number; | ||
| cache: boolean; | ||
|
|
@@ -168,7 +169,12 @@ async function fetchFirstAvailableAssertionArtifact( | |
| if (remote.verifiedBytes) return { availability: 'verified', remote, sourcePeerId }; | ||
| const page = remote.response; | ||
| if (!page.denied && !page.unavailable && !page.hashMismatch && page.bytesB64 != null) { | ||
| return { availability: 'unverified_page', remote, sourcePeerId }; | ||
| const result: AssertionArtifactRemoteResult = { availability: 'unverified_page', remote, sourcePeerId }; | ||
| if (opts.cache && !opts.explicitSourcePeerId) { | ||
| fallback ??= result; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Bug: This keeps the first fallback even when it is only |
||
| continue; | ||
| } | ||
| return result; | ||
| } | ||
| fallback ??= { availability: 'unavailable', remote, sourcePeerId }; | ||
| } | ||
|
|
@@ -325,6 +331,7 @@ export async function handleKaImportArtifactRead(ctx: RequestContext): Promise<v | |
| const cache = raw.cache !== false && offset === 0; | ||
| const fetched = await fetchFirstAvailableAssertionArtifact(agent, resolved, { | ||
| sourcePeerIds, | ||
| explicitSourcePeerId: Boolean(sourcePeerId), | ||
| offset, | ||
| maxBytes, | ||
| cache, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Issue: This only exercises the
cache: falsereadRequestedPage path. The PR also added decoded-length guards in the cache-promotion path for the first page and subsequent pages, which is the path that can assembleverifiedBytesand promote bytes into the file store. A regression in those guards would not fail this suite. Addcache: truecases for an oversized first page and an oversized later page, assertinghashMismatch,bytesB64cleared, and noverifiedBytes.