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

🐛 Bug Report — Runtime APIs - R2Conditional parses wildcard etag as strong etag #2572

Closed
harshal317 opened this issue Aug 21, 2024 · 0 comments

Comments

@harshal317
Copy link
Contributor

harshal317 commented Aug 21, 2024

Was looking into this issue here: cloudflare/workers-sdk#6411

Specifically when using the R2Conditional type when passing in an onlyIf option for R2_BINDING.put() we parse this as a strong etag regardless of the content

R2Bucket::UnwrappedConditional::UnwrappedConditional(const Conditional& c)
: secondsGranularity(c.secondsGranularity.orDefault(false)) {
KJ_IF_SOME(e, c.etagMatches) {
JSG_REQUIRE(!isQuotedEtag(e.value), TypeError,
"Conditional ETag should not be wrapped in quotes (", e.value, ").");
etagMatches = buildSingleStrongEtagArray(e.value);
}
KJ_IF_SOME(e, c.etagDoesNotMatch) {
JSG_REQUIRE(!isQuotedEtag(e.value), TypeError,
"Conditional ETag should not be wrapped in quotes (", e.value, ").");
etagDoesNotMatch = buildSingleStrongEtagArray(e.value);
}
KJ_IF_SOME(d, c.uploadedAfter) {
uploadedAfter = d;
}
KJ_IF_SOME(d, c.uploadedBefore) {
uploadedBefore = d;
}
}

As a result when the conditional check is done in the R2 layer the condition which is meant to always be true when an object exists ends up being false.

Mostly creating this for tracking, I'll take a stab at updating the runtime to build a wildcard etag when we are passed a *

harshal317 added a commit to harshal317/workerd that referenced this issue Aug 27, 2024
This commit addresses issue cloudflare#2572
harshal317 added a commit to harshal317/workerd that referenced this issue Aug 27, 2024
This commit addresses issue cloudflare#2572
harshal317 added a commit to harshal317/workerd that referenced this issue Aug 27, 2024
This commit addresses issue cloudflare#2572
harshal317 added a commit to harshal317/workerd that referenced this issue Aug 27, 2024
This commit addresses issue cloudflare#2572
harshal317 added a commit to harshal317/workerd that referenced this issue Sep 6, 2024
This commit addresses issue cloudflare#2572
harshal317 added a commit to harshal317/workerd that referenced this issue Sep 10, 2024
This commit addresses issue cloudflare#2572
@anonrig anonrig closed this as completed Sep 18, 2024
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

No branches or pull requests

2 participants