Skip to content

KV: backup:{timestamp} keys accumulate forever with no TTL or cleanup #106

@davidcampbelldc

Description

@davidcampbelldc

Problem

functions/api/billing/backup/trigger-backup.js writes a new KV key (backup:{timestamp}) on every manual trigger. These keys have:

  • No TTL — never expire
  • No cleanup — old keys are never deleted
  • Unbounded accumulation — each trigger adds a new key permanently

The GET handler lists up to 10 keys for display (backups.slice(0, 10)) but doesn't delete older ones.

Risk

Low — this is manual-trigger only, not scheduled. But keys will accumulate indefinitely, contributing to KV storage quota over time.

Fix

Add expirationTtl: 2592000 (30 days) to the kv.put() call, or add a cleanup step that deletes keys older than N days after listing.

Files

  • functions/api/billing/backup/trigger-backup.js (line ~26)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions