Repository navigation
🐛 Ignore invalid If-Modified-Since in catalogd metas handler - #3214
Merged
openshift-merge-bot[bot] merged 1 commit intoNov 30, 2026
Merged
openshift-merge-bot[bot] merged 1 commit into
openshift-merge-bot[bot] merged 1 commit into
Conversation
checkIfModifiedSince called httpError when the If-Modified-Since header could not be parsed, which wrote a 500 response, and then returned condNone, so handleV1Metas went on to stream the catalog into the same response. Clients got a 500 status whose body was "500 Internal Server Error" followed by the catalog content. RFC 9110 section 13.1.3 says a recipient must ignore If-Modified-Since when its value is not a valid HTTP-date, and that is what the upstream net/http code this file was copied from does (and what the /api/v1/all endpoint already does through http.ServeContent). Drop the httpError call and the now unused ResponseWriter parameter. Add handler tests for a 304 on an unchanged catalog, a 200 when it changed, and a 200 with the plain catalog body for an invalid date. Signed-off-by: Andre Devay <andretorresdg@alumni.usp.br>
👷 Deploy request for olmv1 pending review.Visit the deploys page to approve it
|
tmshort
reviewed
Nov 30, 2026
| t, err := parseTime(ims) | ||
| if err != nil { | ||
| httpError(w, err) | ||
| // RFC 9110 section 13.1.3: an invalid HTTP-date must be ignored. |
Member
There was a problem hiding this comment.
This behavior now mirrors the checkIfUnmodifiedSince() behavior.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: tmshort The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
openshift-merge-bot
Bot
merged commit Nov 30, 2026
4cab3cf
into
operator-framework:main
32 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When a request to
/{catalog}/api/v1/metascarries anIf-Modified-Sinceheader that is not a valid HTTP-date,checkIfModifiedSincecallshttpError, which writes a500 Internal Server Errorresponse, and then returnscondNone.checkPreconditionstherefore returnsfalse, andhandleV1Metasgoes on to stream the catalog into the same response. The client gets status 500 with a body of500 Internal Server Error\nfollowed by the catalog content (and the server logs anHTTP errorat error level).RFC 9110 section 13.1.3 says a recipient MUST ignore
If-Modified-Sinceif the value is not a valid HTTP-date. That is what the upstreamnet/http/fs.gocode this file was copied from does, and what the/api/v1/allendpoint already does because it useshttp.ServeContent. This change drops thehttpErrorcall (and thehttp.ResponseWriterparameter that was only used for it), so an invalid date is ignored and the catalog is served normally.Reproduction before the fix:
Added
TestHandleV1Metas_IfModifiedSincetointernal/catalogd/server/handlers_test.go, covering a 304 when the catalog is unchanged, a 200 when it changed, and a 200 with only the catalog body when the date is invalid. Note on #2879 (open): it also changes this branch ofcheckIfModifiedSince, keeping the 500 but stopping the catalog from being streamed after it. This PR instead follows RFC 9110 and ignores the invalid header, asnet/httpand/api/v1/alldo. The two touch the same lines, so whichever merges second needs a small rebase; happy to adjust to whichever behaviour you prefer.How I tested
go test ./internal/catalogd/server/: the newinvalid date is ignoredcase fails without the fix (status 500, error text prepended to the body) and passes with it. The other cases pass in both.go test ./internal/catalogd/storage/(which includes anIf-Modified-Sinceintegration case) passes.go tool golangci-lint run ./internal/catalogd/server/...: 0 issues.Reviewer Checklist
Summary by CodeRabbit
If-Modified-Sincedates are now ignored, allowing catalog metadata requests to return the content normally.