Skip to content

fix(storage): return already_exists for a duplicate entry - #277

Merged
LouisHaftmann merged 4 commits into
falcondev-oss:devfrom
pcmxgti:fix/dual-keys
Oct 23, 2026
Merged

LouisHaftmann merged 4 commits into
falcondev-oss:devfrom
pcmxgti:fix/dual-keys

Conversation

@pcmxgti

@pcmxgti pcmxgti commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

GitHub rejects a duplicate in-flight reservation with 409 already_exists. The server returned 200 with ok: false, so clients such as BuildKit's gha cache could not tell a duplicate from a failure.

createUpload() now throws AlreadyExistsError, which maps to a 409 response.

Fixes #276

GitHub rejects a duplicate in-flight reservation with 409 already_exists.
The server returned 200 with `ok: false`, so clients such as BuildKit's gha
cache could not tell a duplicate from a failure.

`createUpload()` now throws AlreadyExistsError, which maps to a 409 response.

Fixes falcondev-oss#276
Comment thread lib/storage.ts Outdated
.select('id')
.executeTakeFirst()
if (existingUpload) return
if (existingUpload) throw new AlreadyExistsError('upload')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I could have just checked an empty return, but felt like a brittle check if there are more checks added to createUpload() later on. I took the liberty of creating a new error class.

I can always go back to just checking an empty return if you think that's more aligned with the codebase.

LouisHaftmann and others added 3 commits October 23, 2026 11:44
createUpload now throws instead of returning undefined.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	tests/cleanup-lifecycle.test.ts
#	tests/eager-merge.test.ts
…cate

Move the duplicate-reservation test into the protobuf suite with a unique
key, so it also covers a protobuf client receiving the JSON Twirp error.
Include the cache key in AlreadyExistsError's message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LouisHaftmann
LouisHaftmann merged commit 25b48cf into falcondev-oss:dev Oct 23, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate CreateCacheEntry returns 200 {"ok":false} instead of 409 already_exists, breaking BuildKit type=gha exports (v9.8.0)

2 participants