Skip to content

fix: mismatch in respect status code when har-output option used#2803

Merged
DmitryAnansky merged 4 commits into
mainfrom
fix/har-output-modified-status-code
May 11, 2026
Merged

fix: mismatch in respect status code when har-output option used#2803
DmitryAnansky merged 4 commits into
mainfrom
fix/har-output-modified-status-code

Conversation

@DmitryAnansky
Copy link
Copy Markdown
Contributor

@DmitryAnansky DmitryAnansky commented May 11, 2026

What/Why/How?

  • Fixed mismatch in respect status code when har-output option used.
  • Handle empty body response.

Reference

Closes: https://github.com/Redocly/redocly/issues/23084

Testing

Screenshots (optional)

Check yourself

  • This PR follows the contributing guide
  • All new/updated code is covered by tests
  • Core code changed? - Tested with other Redocly products (internal contributions only)
  • New package installed? - Tested in different environments (browser/node)
  • Documentation update has been considered

Security

  • The security impact of the change has been considered
  • Code follows company security practices and guidelines

Note

Medium Risk
Changes the respect HAR logging fetch wrapper to stop reconstructing responses and to handle bodyless responses, which could subtly affect response streaming/consumption behavior. Covered by new tests, but touches request/response handling in a core command path.

Overview
Fixes respect --har-output so HAR capture no longer alters the returned Response (preserving the original status/statusText and avoiding a status-code mismatch).

Updates withHar to read response data from clone()s (including special-casing body === null for no-content responses) and to attach harEntry directly to the original response. Adds new unit tests covering status preservation and 204/no-body behavior, and includes a patch changeset for @redocly/cli.

Reviewed by Cursor Bugbot for commit 2f2c258. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 11, 2026

🦋 Changeset detected

Latest commit: 2f2c258

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@redocly/cli Patch
@redocly/openapi-core Patch
@redocly/respect-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 2026

CLI Version Mean Time ± Std Dev (s) Relative Performance (Lower is Faster)
cli-latest 1.921s ± 0.031s ▓ 1.01x
cli-next 1.907s ± 0.012s ▓ 1.00x (Fastest)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 80.66% (🎯 80%) 7184 / 8906
🔵 Statements 80.04% (🎯 79%) 7463 / 9323
🔵 Functions 83.67% (🎯 83%) 1435 / 1715
🔵 Branches 72.31% (🎯 71%) 4875 / 6741
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/cli/src/commands/respect/har-logs/with-har.ts 81.81% 65.57% 42.85% 82.81% 39, 80-83, 97, 128, 133, 153-154, 204, 212, 222-225
Generated in workflow #9760 for commit 2f2c258 by the Vitest Coverage Report Action

@DmitryAnansky DmitryAnansky marked this pull request as ready for review May 11, 2026 09:17
@DmitryAnansky DmitryAnansky requested review from a team as code owners May 11, 2026 09:17
Comment thread packages/cli/src/commands/respect/har-logs/with-har.ts Outdated
@DmitryAnansky DmitryAnansky requested a review from tatomyr May 11, 2026 09:23
Comment thread .changeset/chilly-banks-act.md Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b14a347. Configure here.

Comment thread packages/cli/src/commands/respect/har-logs/with-har.ts Outdated
@DmitryAnansky DmitryAnansky merged commit 2deb9d5 into main May 11, 2026
45 checks passed
@DmitryAnansky DmitryAnansky deleted the fix/har-output-modified-status-code branch May 11, 2026 10:10
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.

3 participants