Skip to content

Fix HTTP analysis ignores expectedResponse #7396 - #7410

Open
JbravoI wants to merge 4 commits into
pipe-cd:masterfrom
JbravoI:fix_7396
Open

JbravoI wants to merge 4 commits into
pipe-cd:masterfrom
JbravoI:fix_7396

Conversation

@JbravoI

@JbravoI JbravoI commented Sep 22, 2026 •

Copy link
Copy Markdown

What this PR does

Makes HTTP analysis enforce a configured expectedResponse. After the HTTP status code succeeds, the provider reads the response body and requires an exact match with expectedResponse. An empty expectedResponse preserves the existing status-code-only behavior.

The response body read is limited to 1 MiB to prevent unbounded memory use.

Why we need it

expectedResponse was accepted in HTTP analysis configuration but ignored at runtime. As a result, an analysis could succeed when an endpoint returned the expected status code but an unhealthy or otherwise unexpected response body.

Which issue(s) this PR fixes

Fixes #7396

Does this PR introduce a user-facing change?

Yes.

  • How are users affected by this change: HTTP analysis configurations with a non-empty expectedResponse now fail when the response body does not exactly match the configured value. Configurations without expectedResponse retain their current behavior.
  • Is this breaking change: No. This makes an existing configuration field behave as intended. Users relying on the previous ignored-field behavior can remove expectedResponse if they only want to validate the HTTP status code.
  • How to migrate (if breaking change): Not applicable.

Screenshots/Videos (for documentation or website changes)

Not applicable. This PR updates configuration-reference documentation only; no screenshots or website changes are needed.

@JbravoI
JbravoI requested review from a team as code owners September 22, 2026 18:10
@JbravoI
JbravoI requested review from Warashi, khanhtc1202 and mohammedfirdouss and a lite review from Copilot September 22, 2026 18:10
@netlify

netlify Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for pipecd-site canceled.

Name Link
🔨 Latest commit 36cf0e7
🔍 Latest deploy log https://app.netlify.com/projects/pipecd-site/deploys/6ae4826eb92879c11b3ab9bf

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 review overview

🟢 Approval recommended

The implementation and tests are covered; the only remaining finding is a non-blocking documentation nit.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

Fixes HTTP analysis to enforce configured expectedResponse values while preserving status-only checks when unset.

Changes:

  • Adds exact response-body validation with a 1 MiB read limit.
  • Preserves existing behavior for empty expectedResponse.
  • Adds tests for matching, mismatches, limits, and legacy behavior.
  • Updates configuration wording.
File Summary
pkg/​app/​pipedv1/​plugin/​analysis/​config/​condition.go Documents response validation; a nit remains to clarify exact matching and empty-value behavior in the reference docs.
pkg/​app/​pipedv1/​plugin/​analysis/​analysisprovider/​http/​http.go Implements bounded exact response-body validation.
pkg/​app/​pipedv1/​plugin/​analysis/​analysisprovider/​http/​http_test.go Tests response validation and size-limit behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@harshrajdebug harshrajdebug 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.

I ran this against a handler that writes its body with json.NewEncoder(w).Encode(...) as its last step, which is a common way for a Go health endpoint to respond. The encoder appends a newline, so the body is {"status":"healthy"}\n and the check fails with the config from #7396, where the value is the single-quoted '{"status":"healthy"}' string. It passes when the value is written as a YAML block scalar, which keeps the trailing newline.

With the default failureLimit of 0, that first mismatch fails the ANALYSIS stage. Anyone who already has expectedResponse set today, where it was ignored, and whose endpoint ends its body with a newline would start seeing failures after upgrading with nothing changed on their side.

Would it make sense to trim trailing newlines from the body before comparing? If exact match is the intended rule, the docs should say so. The Copilot comment about the docs has a "Resolved" reply, but analysis.md isn't changed in this PR, so its expectedResponse row still just reads "Expected response body."

@JbravoI
JbravoI requested a review from a team as a code owner September 28, 2026 23:41
@JbravoI

JbravoI commented Sep 28, 2026

Copy link
Copy Markdown
Author

Hi @harshrajdebug

Kindly assist in reviewing, as I have made the necessary changes in commit f2b3b4b

@harshrajdebug harshrajdebug 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.

Thanks, f2b3b4b covers it. I re-ran the handler that writes its body with json.NewEncoder(w).Encode(...) as its last step on this head. The single-quoted value fails with "unexpected response body", the value that keeps the trailing newline passes, and an empty expectedResponse still checks only the status code, which is what the analysis.md row now says. The user-facing section already covers configs where expectedResponse was ignored before, so nothing else from my side on the code.

One small thing in the description: the Screenshots section still says the PR does not modify documentation, which changed with f2b3b4b.

@JbravoI

JbravoI commented Sep 30, 2026

Copy link
Copy Markdown
Author

Hi @harshrajdebug

Kindly assist in reviewing, as I have made the necessary changes to the description.

Thanks.

@harshrajdebug harshrajdebug 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.

The description now matches the change, and the code is unchanged since f2b3b4b apart from the merge from master. The http provider tests pass on this head. Looks good to me.

@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 30.99%. Comparing base (60faf25) to head (36cf0e7).

Files with missing lines Patch % Lines
...edv1/plugin/analysis/analysisprovider/http/http.go 81.81% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7410      +/-   ##
==========================================
+ Coverage   30.95%   30.99%   +0.04%     
==========================================
  Files         602      602              
  Lines       52862    52873      +11     
==========================================
+ Hits        16362    16390      +28     
+ Misses      34956    34935      -21     
- Partials     1544     1548       +4     
Flag Coverage Δ
. 24.83% <ø> (ø)
.-pkg-app-pipedv1-plugin-analysis 30.61% <81.81%> (+1.42%) ⬆️
.-pkg-app-pipedv1-plugin-ecs 34.97% <ø> (ø)
.-pkg-app-pipedv1-plugin-kubernetes 60.19% <ø> (ø)
.-pkg-app-pipedv1-plugin-kubernetes_multicluster 62.25% <ø> (ø)
.-pkg-app-pipedv1-plugin-scriptrun 58.22% <ø> (ø)
.-pkg-app-pipedv1-plugin-terraform 45.66% <ø> (ø)
.-pkg-app-pipedv1-plugin-wait 32.22% <ø> (ø)
.-pkg-app-pipedv1-plugin-waitapproval 55.14% <ø> (ø)
.-pkg-plugin-sdk 52.07% <ø> (+0.17%) ⬆️
.-tool-actions-gh-release 20.00% <ø> (ø)
.-tool-actions-plan-preview 27.91% <ø> (ø)
.-tool-codegen-protoc-gen-auth 0.00% <ø> (ø)

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

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mohammedfirdouss

Copy link
Copy Markdown
Contributor

@JbravoI resolve the conflicts

Signed-off-by: Ewuji John <johnseyi51@gmail.com>
Signed-off-by: Ewuji John <johnseyi51@gmail.com>
Signed-off-by: Ewuji John <johnseyi51@gmail.com>
@JbravoI

JbravoI commented Oct 30, 2026

Copy link
Copy Markdown
Author

78745f8

Conflict resolved in latest commit 78745f8

@mohammedfirdouss

Copy link
Copy Markdown
Contributor

@JbravoI your recent commit is not signed off

Signed-off-by: Ewuji John <johnseyi51@gmail.com>
@JbravoI

JbravoI commented Oct 30, 2026

Copy link
Copy Markdown
Author

@mohammedfirdouss Commits now signed off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP analysis ignores expectedResponse

4 participants