feat: improve observation validation for POST requests #69
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR modifies the
isObjectValidForObservation
function to improve the handling of POST requests. Previously, the validation relied on the presence of a non-empty response body. However, some APIs (e.g., the one mentioned in the related issue) return an empty body on successful creation, leading to incorrect behavior where the provider attempts repeated creation attempts.The updated logic now checks for a non-zero
StatusCode
, ensuring that valid responses are not incorrectly excluded from observation.Why is this change needed?
The existing logic fails for APIs that respond with an empty body on successful creation (e.g., HTTP 201). This causes unnecessary retries and results in conflicts (HTTP 409). By updating the validation logic, we ensure proper handling of such cases.
Changes Made
isObjectValidForObservation
function:cr.Status.Response.Body != ""
tocr.Status.Response.StatusCode != 0
.Related Issues
Resolves: #68