SoftInstigate / restheart

Rapid API Development with MongoDB
https://restheart.org
GNU Affero General Public License v3.0
805 stars 171 forks source link

POST WITH EXPLICIT SECONDARYPREFFERED --> RANDOMLY ID=_null #456

Closed WT2 closed 1 year ago

WT2 commented 1 year ago

Hi

restheart 7.3.3 mongo 6

On new document creation + explicit secondaryPreferred parameter, returned id (inside Location header) can randomly be "_null": 'Location': 'http://api_dynamic/api/test_database/test_collection/_null'

--> CREATE DOCUMENT REQUEST METHOD POST REQUEST URL https://XXXXXXXXXX/api/test_database/test_collection?readPreference=secondaryPreferred REQUEST HEADERS {'Content-Length': '44', 'X-Is-CloudRun': 'TRUE', 'accept': '/', 'User-Agent': 'python-requests/2.27.1', 'Connection': 'keep-alive', 'X-Was-LoadBalanced': 'TRUE', 'content-type': 'application/json', 'Authorization': 'Basic XXXXXXXXXX', 'Accept-Encoding': 'gzip, deflate'} REQUEST BODY {"last": "VQO9Y452C2", "name": "373YZSAEVE"} RESPONSE HEADERS {'Content-Length': '0', 'X-XSS-Protection': '1; mode=block', 'Auth-Token-Location': '/tokens/opsbatch', 'Auth-Token-Valid-Until': '2023-03-28T11:33:12.353232231Z', 'Access-Control-Expose-Headers': 'Location, ETag, Auth-Token, Auth-Token-Valid-Until, Auth-Token-Location, X-Powered-By', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains; preload', 'Content-Security-Policy': "default-src 'self' https: wss: data: blob: 'unsafe-inline';", 'X-Powered-By': 'origin', 'Server': 'nginx', 'Auth-Token': 'XXXXXXXXXX', 'X-Content-Type-Options': 'nosniff', 'Connection': 'keep-alive', 'ETag': '6422ccf4d41b622daa2850d8', 'Location': 'http://api_dynamic/api/test_database/test_collection/_null', 'Access-Control-Allow-Credentials': 'true', 'Date': 'Tue, 28 Mar 2023 11:18:12 GMT', 'Access-Control-Allow-Origin': '*', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'Content-Type': 'application/json', 'X-Frame-Options': 'DENY', 'Permissions-Policy': 'interest-cohort=()'} RESPONSE COOKIES {} RESPONSE CONTENT
RESPONSE STATUS CODE 201 RESPONSE ERROR MESSAGE
CREATED True UPDATED False DELETED False RETRIEVED False SUCCESS True ID _null ETAG 6422ccf4d41b622daa2850d8

ujibang commented 1 year ago

I pushed a possible fix for this.

Can you please test it with the following snapshot release:

docker pull softinstigate/restheart-snapshot:85f5a1c
WT2 commented 1 year ago

Hello

I confirm this one i no longer reproduce it with your snapshot (~200 POST tests)