Skip to content

fix(service): reject objects exceeding MAX_OBJECT_SIZE - #230

Merged
shikhar merged 1 commit into
mainfrom
fix/reject-oversized-objects
Nov 20, 2026
Merged

shikhar merged 1 commit into
mainfrom
fix/reject-oversized-objects

Conversation

@shikhar

@shikhar shikhar commented Nov 20, 2026

Copy link
Copy Markdown
Member

Summary

CacheValueHeader stores object_size in 40 bits (up to 1 TiB - 1), so objects of size >= 1 TiB were cached in memory and then silently dropped when evicted to foyer's disk cache.

This change keeps the on-disk format untouched and explicitly rejects objects larger than MAX_OBJECT_SIZE ((1 << 40) - 1) up front:

  • Define MAX_OBJECT_SIZE = MAX_RANGE_END - 1 ((1 << 40) - 1) in src/service/mod.rs and share it with CacheValueHeader::new (with a compile-time < (1 << 40) assertion).
  • Add DownloadError::ObjectTooLarge { object_size, max_object_size } and reject oversized objects in Downloader::download, in Downloader::read_response (before allocating/streaming the body), and in CacheyService::get.
  • Reject C0-Object-Size > MAX_OBJECT_SIZE with 400 Bad Request in ObjectSizeHeader, and map DownloadError::ObjectTooLarge to 422 Unprocessable Entity (object_too_large) in on_chunk_error.

Verification

  • cargo +nightly fmt
  • cargo clippy --locked --all-features --all-targets -- -D warnings --allow deprecated
  • cargo deny check
  • cargo nextest run --locked --lib

Closes #217

Reject objects larger than MAX_OBJECT_SIZE (1 TiB - 1 byte), matching the 40-bit object_size field in CacheValueHeader, instead of caching them in memory and silently dropping them during disk eviction.

Closes #217
@greptile-apps

greptile-apps Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Rejects objects larger than (1 << 40) - 1 before they enter the cache.

  • Objects above the cache limit now get rejected before caching.

Reviews (1) · Last reviewed commit: "fix(service): reject objects exceeding M..." · Reviewed by Greptile

@shikhar
shikhar merged commit 27072a3 into main Nov 20, 2026
8 checks passed
@shikhar
shikhar deleted the fix/reject-oversized-objects branch November 20, 2026 18:57
@github-actions github-actions Bot mentioned this pull request Nov 20, 2026
shikhar pushed a commit that referenced this pull request Nov 20, 2026
## 🤖 New release

* `cachey`: 0.13.5 -> 0.13.6

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[0.13.6](0.13.5...0.13.6)
- 2026-11-20

### Fixed

- *(service)* reject objects exceeding MAX_OBJECT_SIZE
([#230](#230))
- *(object_store)* re-validate rescues, cap timeout allowance, and
require admission for overload copies
([#229](#229))
- *(service)* bound max_attempts in C0-Config and retry overrides
([#228](#228))

### Other

- *(deps)* upgrade dependencies
([#226](#226))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

[Detail Bug] Disk cache silently drops entries for 1 TiB+ objects due to object_size serialization limit

1 participant