Skip to content

fix(analysis)!: evaluate success/failure conditions for non-JSON web metric responses. Fixes #4535#4770

Open
something-ai-hash wants to merge 4 commits into
argoproj:masterfrom
something-ai-hash:fix/4535-web-metric-non-json-evaluate
Open

fix(analysis)!: evaluate success/failure conditions for non-JSON web metric responses. Fixes #4535#4770
something-ai-hash wants to merge 4 commits into
argoproj:masterfrom
something-ai-hash:fix/4535-web-metric-non-json-evaluate

Conversation

@something-ai-hash

@something-ai-hash something-ai-hash commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a bug where the web metric provider always returned Successful for empty or non-JSON HTTP response bodies, without evaluating successCondition / failureCondition.

When json.Unmarshal failed, the code hardcoded AnalysisPhaseSuccessful. Now it passes the response body string to evaluate.EvaluateResult, consistent with the JSON code path.

Fixes #4535

Changes

  • metricproviders/webmetric/webmetric.go: evaluate conditions for non-JSON/empty responses instead of always succeeding
  • metricproviders/webmetric/webmetric_test.go: add regression tests for empty and plain-text bodies; update existing non-JSON tests to use meaningful conditions

Test plan

  • go test ./metricproviders/webmetric/... -count=1
  • golangci-lint run ./metricproviders/webmetric/...

Checklist:

…ixes argoproj#4535

Signed-off-by: Rohit Raj <rohitraj@Rohits-MacBook-Air.local>
@something-ai-hash something-ai-hash requested a review from a team as a code owner June 9, 2026 13:03
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Published E2E Test Results

  4 files    4 suites   3h 46m 3s ⏱️
122 tests 113 ✅  7 💤 2 ❌
490 runs  460 ✅ 28 💤 2 ❌

For more details on these failures, see this check.

Results for commit a4385b0.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Published Unit Test Results

2 504 tests   2 504 ✅  3m 22s ⏱️
  130 suites      0 💤
    1 files        0 ❌

Results for commit a4385b0.

♻️ This comment has been updated with latest results.

@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.03%. Comparing base (0b529dc) to head (a4385b0).
⚠️ Report is 11 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4770      +/-   ##
==========================================
- Coverage   85.04%   85.03%   -0.01%     
==========================================
  Files         166      166              
  Lines       19091    19093       +2     
==========================================
  Hits        16236    16236              
- Misses       2001     2002       +1     
- Partials      854      855       +1     
Flag Coverage Δ
e2e 52.97% <0.00%> (-0.02%) ⬇️
unit-tests 81.37% <100.00%> (-0.02%) ⬇️

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.

@something-ai-hash

Copy link
Copy Markdown
Contributor Author

Hii @kostis-codefresh , can you please review this pr once.

@kostis-codefresh kostis-codefresh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for the contribution.

I have two points though

  1. This breaks existing behavior for users that depended on the "bug". If somebody had conditions defined on a non-JSON or empty response body, those conditions are now actually evaluated. If this PR is merged at the very least we should document this in the release notes. FYI @zachaller

Also it is important to note that the original PR at https://github.com/argoproj/argo-rollouts/pull/1212/files has tests marked as When_200Response_And_EmptyBody_Then_Succeed, When_200Response_And_NilBody_Then_Succeed so for some existing users this might seem like breaking documented behavior.

  1. The new behavior does something that is not documented anywhere. The web metric documentation says that "The webhook response must return JSON content.". But if this PR is merged this is not true anymore.

If this PR is merged now there is another valid scenario. The web metric call now returns pure text "I am OK" and if successconditionm is return == "I am OK", the analysis will pass even though there is no JSON content anywhere.

I think at the very least the documentation must also be updated to explain that simple text responses are also accepted and show at least one scenario.

Update web metrics docs to describe plain-text response handling and add an example.

BREAKING CHANGE: Web metric provider now evaluates successCondition and
failureCondition for empty and non-JSON response bodies instead of always
returning Successful. Users who relied on the previous behavior (conditions
ignored for non-JSON/empty bodies) must update their AnalysisTemplates.

Signed-off-by: Rohit Raj <rohitraj@Rohits-MacBook-Air.local>
@something-ai-hash something-ai-hash requested a review from a team as a code owner June 25, 2026 08:03
@kostis-codefresh kostis-codefresh changed the title fix(analysis): evaluate success/failure conditions for non-JSON web metric responses. Fixes #4535 fix(analysis)!: evaluate success/failure conditions for non-JSON web metric responses. Fixes #4535 Jun 25, 2026
@sonarqubecloud

Copy link
Copy Markdown

@something-ai-hash

Copy link
Copy Markdown
Contributor Author

Hii @kostis-codefresh ,
Thanks for the review, I've addressed both points:

  1. Release notes / Behavior change
    I've added a BREAKING CHANGE footer to the commit message so it will be included in the release changelog.
    The change is intentional per #4535: successCondition and failureCondition are now evaluated for empty and non-JSON response bodies instead of always returning Successful. Users who relied on the old behavior will need to update their AnalysisTemplates.

  2. Documentation
    I've updated docs/analysis/web.md to:

  • Remove the statement that the webhook response must return JSON
  • Add a Plain text responses section with an example where the webhook returns I am OK and successCondition: result == "I am OK"
  • Document that empty bodies assign an empty string to result and conditions are evaluated against it

Kindly review

@kostis-codefresh kostis-codefresh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

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.

Analysis Template Web Provider Succeeds Irrespective Of SuccessCondition/FailureCondition When Response Body is Null Or Not JSON

2 participants