Skip to content

fix(assets): verify uploaded cosmetic size from the R2 listing - #114

Merged
diangogav merged 1 commit into
mainfrom
fix/r2-asset-size-check
Oct 15, 2026
Merged

diangogav merged 1 commit into
mainfrom
fix/r2-asset-size-check

Conversation

@diangogav

Copy link
Copy Markdown
Owner

Summary

Publishing an emote pack failed with HTTP 500:

R2 upload size mismatch for "emote-packs/halloween-duelist/pack.json": local=538, write=538, remote=0

The write reported all 538 bytes, but stat() on the object returned a size of 0. The upload script stored the same file under a probe key and read its size back from the bucket listing, which showed 538 bytes. So the object was stored in full, and stat() reported the wrong size.

R2CosmeticAssetStorage now reads the stored size from list({ prefix }), the same way upload-cosmetic-asset.ts already does. A mismatch, or an object missing from the listing, still deletes the object and fails the publish. A failed publish already deletes the files it uploaded.

Earlier cosmetics published fine because they were mostly larger image files. This was the first upload of a small JSON file.

Verification

  • New R2CosmeticAssetStorage tests:
    • A listed size that matches is accepted even when stat() reports 0.
    • A size mismatch, a missing object or a short write is rejected and deletes the object.
  • bun test: 691 pass, 0 fail.
  • bun run lint and bun run build --noEmit are clean.

stat() reported 0 bytes for a 538-byte pack.json that the bucket listing
showed was stored in full, so publishing an emote pack failed with a size
mismatch. Read the size from list(), as the upload script already does.
@diangogav diangogav self-assigned this Oct 15, 2026
@diangogav
diangogav merged commit acc546d into main Oct 15, 2026
1 check passed
@diangogav
diangogav deleted the fix/r2-asset-size-check branch October 15, 2026 01:17
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.

1 participant