Skip to content

fix: handle invalid if-modified-since - #1426

Merged
ferhatelmas merged 1 commit into
masterfrom
ferhat/invalid-if-modified-since
Sep 22, 2026
Merged

ferhatelmas merged 1 commit into
masterfrom
ferhat/invalid-if-modified-since

Conversation

@ferhatelmas

Copy link
Copy Markdown
Member

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

Invalid if-modified-since header causes 500.

What is the new behavior?

Invalid value is ignored per RFC.

Additional context

https://datatracker.ietf.org/doc/html/rfc9110#section-13.1.3

Copilot AI lite review requested due to automatic review settings September 21, 2026 14:32
@ferhatelmas
ferhatelmas requested a review from a team as a code owner September 21, 2026 14:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good — a small, correct fix for RFC 9110-compliant handling of an invalid If-Modified-Since header.

What was reviewed: the new parseIfModifiedSince helper and its use in both the iceberg and normal GetObject handlers in get-object.ts; traced the resulting Date through s3-handler.ts (toISOString()) down to the backend adapter to confirm the string/undefined expectations in the new test match runtime behavior; confirmed the pre-existing parseDateHeader (used for response-expires) is untouched and unrelated to this change.

Extended reasoning...

Overview

The diff adds a parseIfModifiedSince(input?: string) helper in src/http/routes/s3/commands/get-object.ts that returns undefined for an invalid date string instead of an "Invalid Date" object, per RFC 9110 §13.1.3. Both the iceberg and normal GetObject handlers were switched from manually constructing new Date(ifModifiedSince) to calling this helper, and the now-dead local variable was removed. router.test.ts adds a parametrized it.each test covering an invalid header ("not a date" -> undefined) and a valid RFC-formatted header (-> correct ISO date passed to the backend).

Security risks

None identified. This is a request-header parsing fix with no auth, permission, or data-exposure implications. Previously the bug could propagate an invalid Date object to the storage backend, which is a correctness/availability issue (potential 500 or wrong behavior) rather than a security issue.

Level of scrutiny

Low. The change is small, self-contained, mechanical, and matches an established pattern already used elsewhere in the file (parseDateHeader). It is directly covered by a new test that exercises the actual route through s3Router and backend mock, verifying both the invalid and valid cases end-to-end.

Other factors

I traced the data flow (get-object.ts -> s3-handler.ts's command.IfModifiedSince?.toISOString() -> backend adapter) to confirm the test's expected values (undefined and the ISO string) are consistent with actual runtime behavior, not just the helper's isolated logic. No CODEOWNERS file was found restricting these paths, and no prior review comments exist on this PR to check for being addressed.

@coveralls

coveralls commented Sep 21, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 35702101685

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.03%) to 83.371%

Details

  • Coverage increased (+0.03%) from the base build.
  • Patch coverage: 4 of 4 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 14184
Covered Lines: 12255
Line Coverage: 86.4%
Relevant Branches: 8673
Covered Branches: 6801
Branch Coverage: 78.42%
Branches in Coverage %: Yes
Coverage Strength: 3088.07 hits per line

💛 - Coveralls

Signed-off-by: Ferhat Elmas <elmas.ferhat@gmail.com>
@ferhatelmas
ferhatelmas force-pushed the ferhat/invalid-if-modified-since branch from 35cb07d to d76c842 Compare September 22, 2026 07:55
@ferhatelmas
ferhatelmas enabled auto-merge (squash) September 22, 2026 07:56
@ferhatelmas
ferhatelmas merged commit 7e0d815 into master Sep 22, 2026
32 checks passed
@ferhatelmas
ferhatelmas deleted the ferhat/invalid-if-modified-since branch September 22, 2026 08:03
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

Successfully merging this pull request may close these issues.

4 participants