Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stronger typing for LifecycleRule conditions #2061

Closed
bryfox opened this issue Sep 8, 2022 · 2 comments
Closed

Stronger typing for LifecycleRule conditions #2061

bryfox opened this issue Sep 8, 2022 · 2 comments
Labels
api: storage Issues related to the googleapis/nodejs-storage API. next major: breaking change this is a change that we should wait to bundle into the next major version priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@bryfox
Copy link

bryfox commented Sep 8, 2022

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.

@bryfox bryfox added priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Sep 8, 2022
@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/nodejs-storage API. label Sep 8, 2022
@shaffeeullah
Copy link
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.

@shaffeeullah shaffeeullah added the next major: breaking change this is a change that we should wait to bundle into the next major version label Sep 8, 2022
@ddelgrosso1
Copy link
Contributor

Released with 7.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/nodejs-storage API. next major: breaking change this is a change that we should wait to bundle into the next major version priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

3 participants