Skip to content

Add safety limit to Cloudflare list_keys pagination #202

@aram356

Description

@aram356

Description

The Cloudflare CloudflareKvStore::list_keys implementation paginates through all keys in a KV namespace and accumulates them into a single Vec<String>. On namespaces with a large number of keys, this unbounded accumulation could cause an out-of-memory condition.

What needs to be done

Add a safety limit to list_keys pagination in crates/edgezero-adapter-cloudflare/src/key_value_store.rs:

  • Cap the total number of keys returned (e.g., 10,000) or the total accumulated size
  • Return a clear error when the limit is hit, rather than silently truncating
  • Consider whether list_keys should accept an optional limit parameter at the KvStore trait level

Done when

  • CloudflareKvStore::list_keys has a configurable or hardcoded safety limit
  • Exceeding the limit returns a meaningful KvError
  • Behavior is documented

Affected area

Adapter -- Cloudflare

Context

Identified during PR #165 (KV store feature) review. The current implementation works correctly for small namespaces but poses an OOM risk in production with large key sets.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions