Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Stronger typing for LifecycleRule conditions #2061

Closed

Description

@bryfox

Is your feature request related to a problem? Please describe.

It's easy to write an incorrect lifecycle condition resulting in unwanted results, particularly for a delete action. For example, the following rule uses a string for matchesPrefix when an array of strings is expected.

addLifecycleRule({ action: { type: "Delete" }, condition: { isLive: true, matchesPrefix: "tmp/", age: 1 }})

This rule will be added, but without the prefix condition, so that it (as far as I can tell) applies to all objects in the bucket:

// bucket.metadata.lifecycle.rule
[ { action: { type: 'Delete' }, condition: { age: 1, isLive: true } } ]

Describe the solution you'd like

Stronger typing on the LifecycleRule would help TS users write rules correctly.

(c.f. the go SDK: https://github.com/googleapis/google-cloud-go/blob/5a9102369b64e06a1564b9d769da7bd044035b7e/storage/bucket.go#L649)

Describe alternatives you've considered

The client SDK could throw an error if unexpected types are passed, to protect me from myself. However, gsutil appears to have the same behavior of creating rules while discarding conditions with unexpected types in the JSON.

Activity

  1. added
    priority: p3
    type: feature request
    on Sep 8, 2022
  2. added
    api: storage
    on Sep 8, 2022
  3. shaffeeullah commented on Sep 8, 2022

    @shaffeeullah
    Contributor

    Thanks for calling this out! I can see how this leads to a confusing user experience. We will take another look at this as we plan our next major release, as this would be a breaking change.

  4. added
    next major: breaking change
    on Sep 8, 2022
  5. ddelgrosso1 commented on Aug 3, 2023

    @ddelgrosso1
    Contributor

    Released with 7.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: storagenext major: breaking changepriority: p3type: feature request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions