fix(analysis)!: evaluate success/failure conditions for non-JSON web metric responses. Fixes #4535#4770
Conversation
…ixes argoproj#4535 Signed-off-by: Rohit Raj <rohitraj@Rohits-MacBook-Air.local>
Published E2E Test Results 4 files 4 suites 3h 46m 3s ⏱️ For more details on these failures, see this check. Results for commit a4385b0. ♻️ This comment has been updated with latest results. |
Published Unit Test Results2 504 tests 2 504 ✅ 3m 22s ⏱️ Results for commit a4385b0. ♻️ This comment has been updated with latest results. |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Hii @kostis-codefresh , can you please review this pr once. |
There was a problem hiding this comment.
Thank you for the contribution.
I have two points though
- 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.
- 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>
|
|
Hii @kostis-codefresh ,
Kindly review |



Summary
Fixes a bug where the web metric provider always returned
Successfulfor empty or non-JSON HTTP response bodies, without evaluatingsuccessCondition/failureCondition.When
json.Unmarshalfailed, the code hardcodedAnalysisPhaseSuccessful. Now it passes the response body string toevaluate.EvaluateResult, consistent with the JSON code path.Fixes #4535
Changes
metricproviders/webmetric/webmetric.go: evaluate conditions for non-JSON/empty responses instead of always succeedingmetricproviders/webmetric/webmetric_test.go: add regression tests for empty and plain-text bodies; update existing non-JSON tests to use meaningful conditionsTest plan
go test ./metricproviders/webmetric/... -count=1golangci-lint run ./metricproviders/webmetric/...Checklist:
git commit -s)