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
On put requests to replace existing objects, I am getting “412 - Client and server etags don't match”, even if-match header is correctly set.
I tried to debug the root cause of the problem.
Wanted to explain my findings.
This happens only on endpoints which auth_field is enabled.
When force_auth_field_projection=True -> get_document() function forces to add projection ={ ‘auth_field’ :1} to pymongo query (it is exact added at io/base.py line 511: if force_auth_field_projection:fields[auth_field] = 1). This causes pymongo to return original item, only with fields _id and auth_field.
Object before document.get() in common.py line 120; (Original object has 10+ fields including _etag, but it contains only id and auth field because of force_auth_field_projection=True)
As I mentioned on top, returned item only have _id and auth_field and not _etag; .get() cant find current _etag value in document item and tries to calculate it from document_etag() function, but document item doesnt have all fields, causes_etag value to be calculated incorrectly,
Then I get error 412 etag values doesnt match.
When debugging I manually override force_auth_field_projection=True to False, PUT request runs without any error.
Expected Behavior
PUT requests with auth_field enabled endpoints, should be successful, if _etag value is correctly set in IF-Match header.
Actual Behavior
Getting “412 - Client and server etags don't match” on endpoints which auth_field is enabled, even if-match header is correct.
Environment
Python version: 3.8
Eve version: 1.1.5
The text was updated successfully, but these errors were encountered:
On put requests to replace existing objects, I am getting “412 - Client and server etags don't match”, even if-match header is correctly set.
I tried to debug the root cause of the problem.
Wanted to explain my findings.
This happens only on endpoints which auth_field is enabled.
My findings:
On put.py line 138;
When
force_auth_field_projection=True
->get_document()
function forces to addprojection ={ ‘auth_field’ :1}
to pymongo query (it is exact added at io/base.py line 511:if force_auth_field_projection:
fields[auth_field] = 1
). This causes pymongo to return original item, only with fields_id
andauth_field
.On common.py line 120;
Object before
document.get()
in common.py line 120; (Original object has 10+ fields including _etag, but it contains only id and auth field because of force_auth_field_projection=True)As I mentioned on top, returned item only have
_id
andauth_field
and not_etag
;.get()
cant find current_etag
value indocument
item and tries to calculate it fromdocument_etag()
function, butdocument
item doesnt have all fields, causes_etag
value to be calculated incorrectly,Then I get error 412 etag values doesnt match.
When debugging I manually override
force_auth_field_projection=True
toFalse
, PUT request runs without any error.Expected Behavior
PUT requests with auth_field enabled endpoints, should be successful, if _etag value is correctly set in IF-Match header.
Actual Behavior
Getting “412 - Client and server etags don't match” on endpoints which auth_field is enabled, even if-match header is correct.
Environment
The text was updated successfully, but these errors were encountered: