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

Bug in Put Conditional? #774

@bstopp

Description

@bstopp

I'm trying to use the onlyIf conditional for putting an object into a bucket using R2 Bindings. However, I'm seeing the reverse of operations than expected.

I would expect that if I:

    const update = await env.BUCKET.put(key, 'New Content', { onlyIf: { etagMatches: '*' } });

This will only return an object if there already exists content at the specified key.

Whereas:

    const update = await env.BUCKET.put(key, 'New Content', { onlyIf: { etagDoesNotMatch: '*' } });

Will only save if there is no content at the specified key.

Using Miniflare, my tests show these are reversed, here's a gist for both cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions