Skip to content

Conversation

@martincostello
Copy link
Collaborator

Fix incorrect ETag for compressed files by resetting the compressed stream to the beginning before computing the SHA256 hash.

See #3486 (comment).

Fix incorrect ETag for compressed files by resetting the compressed stream to the beginning before computing the SHA256 hash.

See #3486.
@martincostello martincostello added this to the v9.0.4 milestone Jul 8, 2025
Copilot AI review requested due to automatic review settings July 8, 2025 15:46
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures the compressed stream is reset before computing the hash so that ETag values for compressed files are correct.

  • Reset the compressed stream position in EmbeddedResourceProvider before hashing.
  • Introduce a shared constant for the empty-string hash in tests and replace hard-coded literals.
  • Add assertions to verify the empty-string hash does not appear in the ETag tag.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerUIIntegrationTests.cs Added EmptyStringSha256Hash constant, replaced literals, and added Assert.DoesNotContain checks on ETag.
test/Swashbuckle.AspNetCore.IntegrationTests/ReDocIntegrationTests.cs Mirrored the same constant and assertions changes for ReDoc tests.
src/Shared/EmbeddedResourceProvider.cs Inserted compressed.Seek(0, SeekOrigin.Begin) before hashing.
Comments suppressed due to low confidence (2)

test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerUIIntegrationTests.cs:10

  • The constant name suggests SHA256 but the code uses SHA1; consider renaming it to EmptyStringSha1Hash for accuracy.
    private const string EmptyStringSha256Hash = "2jmj7l5rSw0yVb/vlWAYkK/YBwk=";

test/Swashbuckle.AspNetCore.IntegrationTests/ReDocIntegrationTests.cs:13

  • The constant name suggests SHA256 but the code uses SHA1; consider renaming it to EmptyStringSha1Hash for accuracy.
    private const string EmptyStringSha256Hash = "2jmj7l5rSw0yVb/vlWAYkK/YBwk=";

@martincostello martincostello enabled auto-merge (rebase) July 8, 2025 15:49
@codecov
Copy link

codecov bot commented Jul 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.91%. Comparing base (4903084) to head (e52cc59).
Report is 1 commits behind head on master.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3490   +/-   ##
=======================================
  Coverage   93.91%   93.91%           
=======================================
  Files         110      110           
  Lines        3810     3811    +1     
  Branches      723      723           
=======================================
+ Hits         3578     3579    +1     
  Misses        232      232           
Flag Coverage Δ
Linux 93.91% <100.00%> (+<0.01%) ⬆️
Windows 93.91% <100.00%> (+<0.01%) ⬆️
macOS 93.91% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@martincostello martincostello merged commit 525a8a3 into master Jul 8, 2025
12 checks passed
@martincostello martincostello deleted the fix-etag branch July 8, 2025 15:51
This was referenced Aug 27, 2025
This was referenced Oct 24, 2025
github-actions bot pushed a commit to EelcoLos/nx-tinkering that referenced this pull request Oct 27, 2025
Updated
[swashbuckle.aspnetcore.cli](https://github.com/domaindrivendev/Swashbuckle.AspNetCore)
from 9.0.3 to 9.0.6.

<details>
<summary>Release notes</summary>

_Sourced from [swashbuckle.aspnetcore.cli's
releases](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/releases)._

## 9.0.6

## What's Changed

* Bump redoc from 2.5.0 to 2.5.1 by @​dependabot in
domaindrivendev/Swashbuckle.AspNetCore#3587
* Bump swagger-ui from 5.29.1 to 5.29.2 by @​dependabot in
domaindrivendev/Swashbuckle.AspNetCore#3595

**Full Changelog**:
domaindrivendev/Swashbuckle.AspNetCore@v9.0.5...v9.0.6


## 9.0.5

## What's Changed

* .NET 10 preparation by @​martincostello in
domaindrivendev/Swashbuckle.AspNetCore#3565
* Update NuGet packages by @​martincostello in
domaindrivendev/Swashbuckle.AspNetCore#3573
* Fix anchors by @​martincostello in
domaindrivendev/Swashbuckle.AspNetCore#3577
* Bump swagger-ui-dist from 5.27.1 to 5.29.1

**Full Changelog**:
domaindrivendev/Swashbuckle.AspNetCore@v9.0.4...v9.0.5


## 9.0.4

## What's Changed

* Fix incorrect `ETag` values by @​martincostello in
domaindrivendev/Swashbuckle.AspNetCore#3490
* Fix `Accept-Encoding` parsing by @​martincostello in
domaindrivendev/Swashbuckle.AspNetCore#3492
* Check `Accept-Encoding` quality by @​martincostello in
domaindrivendev/Swashbuckle.AspNetCore#3493
* Update xunit packages by @​martincostello in
domaindrivendev/Swashbuckle.AspNetCore#3500
* Add release notes configuration by @​martincostello in
domaindrivendev/Swashbuckle.AspNetCore#3502
* Simplify release workflow by @​martincostello in
domaindrivendev/Swashbuckle.AspNetCore#3503
* Bump xunit dependencies by @​martincostello in
domaindrivendev/Swashbuckle.AspNetCore#3508
* Update NuGet dependencies by @​martincostello in
domaindrivendev/Swashbuckle.AspNetCore#3513
* Remove `WebHost` usage from tests by @​martincostello in
domaindrivendev/Swashbuckle.AspNetCore#3517
* Fix typos by @​martincostello in
domaindrivendev/Swashbuckle.AspNetCore#3520
* Sign-off commits by @​martincostello in
domaindrivendev/Swashbuckle.AspNetCore#3526
* Add zizmor by @​martincostello in
domaindrivendev/Swashbuckle.AspNetCore#3528
* Fix permissions by @​martincostello in
domaindrivendev/Swashbuckle.AspNetCore#3529
* Bump zizmor by @​martincostello in
domaindrivendev/Swashbuckle.AspNetCore#3535
* Add default `$type` discriminator for `[JsonPolymorphic]` by @​lilinus
in domaindrivendev/Swashbuckle.AspNetCore#3496
* Update NuGet dependencies by @​martincostello in
domaindrivendev/Swashbuckle.AspNetCore#3545

## New Contributors

* @​lilinus made their first contribution in
domaindrivendev/Swashbuckle.AspNetCore#3496

**Full Changelog**:
domaindrivendev/Swashbuckle.AspNetCore@v9.0.3...v9.0.4


Commits viewable in [compare
view](domaindrivendev/Swashbuckle.AspNetCore@v9.0.3...v9.0.6).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=swashbuckle.aspnetcore.cli&package-manager=nuget&previous-version=9.0.3&new-version=9.0.6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants