Check if db exists in /db/_ensure_full_commit call#1588
Conversation
| db_req(#httpd{method='POST', path_parts=[DbName, <<"_ensure_full_commit">>], | ||
| user_ctx=Ctx}=Req, _Db) -> | ||
| chttpd:validate_ctype(Req, "application/json"), | ||
| fabric:get_security(DbName, [{user_ctx, Ctx}]), |
There was a problem hiding this comment.
I think there is a need for a comment here to describe why the call is needed and the reason for fabric:get_security/2 to be used for database existence check (get_security uses local shards while fabric:get_db_info for example uses non local shards as well)
There was a problem hiding this comment.
I'm using get_security here because 1) it is what old code was using 2) get security calls fabric_util:get_db that actually does open remote shards, but gives priority to local ones, so it allows to avoid round-trip when possible 3) it presumably also confirms user to be reader, that what old code was saying, but I don't see it in fabric, tbh.
I can drop a comment here or I can switch to fabric:get_db_info if you think that'd be less subtle.
|
@iilyak ok, updated with the comment. does it look sufficient for you? |
0db097b to
171d135
Compare
We removed a security call in `do_db_req` to avoid a duplicate authorization check and as a result there are now no db validation in noop call `/db/_ensure_full_commit`. This makes it always return a success code, even for missing databases. This fix places the security check directly in _ensure_full_commit call and adds eunit tests for a good measure.
171d135 to
5c0548e
Compare
Overview
We removed a security call in
do_db_reqin #1246 to avoid duplicate authorization check and as a result there are now no db validation in noop call/db/_ensure_full_commit. This makes it always return a success code, even for the missing databases.This fix places the security check directly in
_ensure_full_commitcall and adds eunit tests for a good measure.Testing recommendations
make eunit apps=chttpd suites=chttpd_db_testfor isolated testsRelated Issues or Pull Requests
Closes #1585
Checklist