Skip to content

fix: improve lifecycle log accuracy - #1428

Open
itslenny wants to merge 1 commit into
tyler/feat/object-versioning-wave-3from
lenny/lifecycle-log-fixes-after-versioning
Open

itslenny wants to merge 1 commit into
tyler/feat/object-versioning-wave-3from
lenny/lifecycle-log-fixes-after-versioning

Conversation

@itslenny

@itslenny itslenny commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

The lifecycle event logs used for usage tracking have accuracy issues:

  • ObjectCreated:Put / ObjectCreated:Copy does not include old object size when overwriting an existing object
  • Not logged if webhooks are disabled for the tenant causing usage tracking to be inaccurate
  • Logs emitted in queue job which can cause duplicate entries if the job is retried

What is the new behavior?

  • ObjectCreated:Put / ObjectCreated:Copy add an oldObject field with the replaced object's size. This lets usage be correctly attributed.
  • Emit ObjectRemoved:Delete when a move operation causes an object deletion (e.g. restore version)
  • All lifecycle events:
    • log once at dispatch time, before the event is queued. This prevents double counted usage.
    • emit lifecycle logs if webhooks are disabled

Lifecycle log change

This is an example of a lifecycle log diff after this change including oldObject if there is an object being overwritten

{
  "tenant": {
    "ref": "PROJECT_REF"
  },
  "name": "obj-name.txt",
  "version": "UUID",
  "bucketId": "bucket-name",
  "metadata": {
    "httpStatusCode": 200,
    "cacheControl": "no-cache",
    "eTag": "ETAG",
    "mimetype": "text/plain",
    "contentLength": 56,
    "lastModified": "TIMESTAMP",
    "size": 56
  },
  "reqId": "REQID",
  "uploadType": "standard",
+  "oldObject": {
+    "name": "obj-name.txt",
+    "bucketId": "bucket-name",
+    "version": "UUID",
+    "metadata": {
+      "eTag": "ETAG",
+      "size": 30,
+      "mimetype": "text/plain",
+      "cacheControl": "no-cache",
+      "lastModified": "TIMESTAMP",
+      "contentLength": 30,
+      "httpStatusCode": 200
+    },
    "reqId": "REQID"
  }
}

@itslenny
itslenny added this pull request to stack #1355 September 21, 2026 22:00
@itslenny
itslenny requested a review from a team as a code owner September 21, 2026 22:00

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Comment thread src/storage/object.ts
@itslenny
itslenny force-pushed the lenny/lifecycle-log-fixes-after-versioning branch from 468291e to c1ab0d1 Compare September 22, 2026 14:50

This branch has not been deployed

No deployments
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