Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve observation validation for POST requests #69

Conversation

arielsepton
Copy link
Member

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

  • Updated the isObjectValidForObservation function:
    • Changed the check from cr.Status.Response.Body != "" to cr.Status.Response.StatusCode != 0.
    • This ensures that the validation focuses on the status code rather than the presence of a body.
  • Updated the related unit tests.

Related Issues

Resolves: #68

Signed-off-by: Ariel Septon <arielsepton@Ariels-MBP.lan>
@arielsepton arielsepton merged commit 4758bde into crossplane-contrib:main Nov 26, 2024
7 checks passed
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.

Interfacing with APIs that return empty response on CREATE
1 participant