You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a resource state is refreshed, the provider tries to read the resource from the API.
If the read fails with a 404, we set obj.id = "" causing a recreation of the resource. This works in the following cases:
The read requests returns a 404
The read request returns a 200 but there was read_search properties provided and there was an error while searching the resource in the results (e.g. unknown results_key, unknown search_key, etc.)
However, when the resource was not found with read_search, the resource is not marked for creation!
Expected behaviour: If the resource was not found during state refresh (either because the API returned a 404 or the search did not return a result), the resource should be marked for creation.
Investigation
The issue is that when the object is read in this line, we use the findObject method and check, whether it returns an error. The error is returned in many cases but it is not returned, if the object exists in the state but was not found using in the findObject method. This behaviour can be seen in this line. There, we only return an error if the object id was "", but not if it existed before.
I'm not sure where the best place to fix this issue is without breaking existing functionality. I'd assume that the best place to check would be in the readObject method. Here, we could extend the check to not only set obj.id = "" if there was an error, but also if objFound is undefined.
The text was updated successfully, but these errors were encountered:
When a resource state is refreshed, the provider tries to read the resource from the API.
If the read fails with a 404, we set
obj.id = ""
causing a recreation of the resource. This works in the following cases:read_search
properties provided and there was an error while searching the resource in the results (e.g. unknownresults_key
, unknownsearch_key
, etc.)However, when the resource was not found with
read_search
, the resource is not marked for creation!Expected behaviour: If the resource was not found during state refresh (either because the API returned a 404 or the search did not return a result), the resource should be marked for creation.
Investigation
The issue is that when the object is read in this line, we use the
findObject
method and check, whether it returns an error. The error is returned in many cases but it is not returned, if the object exists in the state but was not found using in thefindObject
method. This behaviour can be seen in this line. There, we only return an error if the object id was "", but not if it existed before.I'm not sure where the best place to fix this issue is without breaking existing functionality. I'd assume that the best place to check would be in the
readObject
method. Here, we could extend the check to not only setobj.id = ""
if there was an error, but also ifobjFound
is undefined.The text was updated successfully, but these errors were encountered: