-
Notifications
You must be signed in to change notification settings - Fork 134
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
Noticed the following ONA Data API limitations: #2472
Comments
|
@machariamuguku For number 2, it appears its working fine with only the caveat that |
The path to resolution:
"_date_modified": "2023-06-14T14:52:06", To: "_date_modified": "2023-06-14T14:52:06.940826+00:00",
{
"detail": "invalid input syntax for type timestamp with time zone: \"2020-12-18T09:36:19.767455 00:00\"\nLINE 1: ...65119) AND deleted_at IS NULL AND date_modified > '2020-12-1...\n ^\n"
}
|
The The work around that can be applied at the moment is to encode it to Also the reason this was not caught by our tests is because the test cases testing this functionality use APIRequestFactory instead of APIClient. APIClient mimicks the browser. While using it, I have been able to replicate the bug in the test cases cc @ukanga @machariamuguku |
@ukanga Should we have the client amend the URL to encode the + or should we have the API apply fix to reformat the value as desired? |
I think the fix should be on the client side, but that the test cases should be updated. + to space is standard encoding. I think it could get really messy if we start adding exceptions to how those are interpreted. |
@kelvin-muchiri The API client I'm using encodes the request and it still returns the error: This request: ?query={"_date_modified": {"$gt": "2020-12-18T09:36:19.767455+00:00"}}&page_size=1 Is encoded to ?query=%7B%22_date_modified%22%3A%20%7B%22%24gt%22%3A%20%222020-12-18T09%3A36%3A19.767455%2B00%3A00%22%7D%7D&page_size=1 But it still fails with: {
"detail": "invalid input syntax for type timestamp with time zone: \"2020-12-18T09:36:19.767455 00:00\"\nLINE 1: ...65119) AND deleted_at IS NULL AND date_modified > '2020-12-1...\n ^\n"
} Looks like a decoding error |
@machariamuguku When I test on the browser without the encoding, I get the 400 error but with the encoding, I am getting a successful response |
@machariamuguku Maybe you need to encode the value of the values - in this case, encoding this portion by itself before including it in the query - |
@ukanga @kelvin-muchiri My bad, turns out the request is encoded properly ( |
@ukanga The dates in get_full_dict (
Therefore Should we be updating the |
Yeah, I think you have a point @kelvin-muchiri. It was an invalid input, and resulted in a meaningful error message to the client. I do wonder if there might be a better way to signal to clients what's going on. Might be something to talk through with @machariamuguku, to see if there might have been a way to make the issue more obvious to someone scanning the response. |
Hm. I think, in a perfect world, we shouldn't be tracking this info in two different places. Might the suggested approach result in auto_now being called yet again, since the json is a property of the model, which is being modified in its own post-save signal? And wouldn't that result in the same problem, and be a possible recipe for resource contention? Maybe instead of having auto_now on the date_modified field, the code could use the same explicitly set timestamp for both the field and the json (in an overridden save method, or something similar). |
Thanks @okal hadn't thought of this case, leads us back to square 1 |
@okal I agree, an alternative option would be to set them explicitly and remove reliance of |
@okal I was of the opinion the metadata can be added when serializing the response, but @ukanga pointed out that the reason the metadata is stored in the DB during save is to ensure no further calculation is done when rendering the response. However, can't we have the update happen when rendering the response then rely on caching to store the results for some time X thus reducing the frequency of recalculations? |
But from what I see from the code is that alot is going on such as getting the attachments, notes e.t.c which are expensive operations which makes sense to perform them before hand |
We may then need to switch to using the |
@ukanga Thanks, I think I might need to create a new issue for this and handle it in a separate PR? |
@ukanga I have create a separate issue Instance model date_modified and date_created fields are out of sync with their aliases in the json field |
_date_modified
field. This is a challenge as that's the field we use as a cursor field_last_edited
or the_submission_time
is patchy and creates loopholes?query={"_date_modified": {"$gt": "2023-07-18T19:09:52"}}
returns records with_date_modified
matching the exact filter?query={"_date_modified": {"$gte": "2023-07-18T19:09:52"}}
has the same effect&query={"_date_modified": {"$gt": "2023-07-05T16:56:32.172+02:00"}}
_date_modified
,_last_edited
, and_submission_time
links
header) when using sorting?page=1&page_size=2&sort={"_date_modified": 1}
this does not return links header?page=1&page_size=2
this doesOriginally posted by @machariamuguku in https://github.com/onaio/source-ona-data/issues/19#issuecomment-1702914169
The text was updated successfully, but these errors were encountered: