File-based DB support implementation is not usable out-of-the-box and deviates from the mongo implementation · Issue #948 · finos/git-proxy · GitHub
More Web Proxy on the site http://driver.im/
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
Describe the bug
There appear to be a number of flaws in the file-based DB implementation that impede its use. These include some small deviations from the mongo implementation AND some deviations in behaviotr between @seald/nedb and mongo that should be handled in the implementation.
lowercasing of inputs (particularly of usernames and emails) is inconsistently applied and differs from mongo implementation. In places, inputs are lowercased before being sent to the database client and hence apply to both client implementations, however, the mongo clients applies lowercasing on its own in other situations. The database clients should consistently lowercase inputs where appropriate (in both record creation and query) to ensure consistent application. Example of deviation (there are many more cases):
(note exactly one user must be found on line 17 - yet we are not actually filtering users)
The implementation does not merge records on update, but replaces them. This causes fields not supplied in the update to be dropped (e.g. if a user is updated on login via an SSO integration, then the Github user name is dropped as that is manually entered later).
(this looks correct by @seald/nedb does not actually merge records when called like this - it finds the existing record and replaces it with the user passed in. This needs rewriting to either use the $set keyword or to manually retrieve the existing doc and merge into before calling db.update.
neDB implementations should be set to compact their data files periodically, unless they are restarted regularly (compacts on read) - neDB uses an append-only file format so it will create many duplicate lines, See https://github.com/seald/nedb?tab=readme-ov-file#persistence. Add calls to set-up compaction to avoid infinite growth and very redundant data files.
No indexes are applied, which will result in performance losses as the dataset grows. Add calls to create indexes supporting common queries - these calls should be made on every start-up. See: https://github.com/seald/nedb?tab=readme-ov-file#indexing for details Expected behavior
The behaviour of the file-based DB support should match that of the mongo implementation and it should work out-of-the-box.
Additional context
I'll raise a PR to address these issues in the implementation.
The text was updated successfully, but these errors were encountered:
@grovesy understood on the intention, it remains useful for that purpose and I can see others using it. As we've just about got it working here I'd be happy to contribute the fixes to bring it up to spec (although perhaps not to an enterprise grade ;-) ).
Describe the bug
There appear to be a number of flaws in the file-based DB implementation that impede its use. These include some small deviations from the mongo implementation AND some deviations in behaviotr between @seald/nedb and mongo that should be handled in the implementation.
lowercasing of inputs (particularly of usernames and emails) is inconsistently applied and differs from mongo implementation. In places, inputs are lowercased before being sent to the database client and hence apply to both client implementations, however, the mongo clients applies lowercasing on its own in other situations. The database clients should consistently lowercase inputs where appropriate (in both record creation and query) to ensure consistent application. Example of deviation (there are many more cases):
git-proxy/src/db/mongo/repo.js
Lines 41 to 45 in 5d24d9d
git-proxy/src/db/file/repo.js
Lines 54 to 73 in 5d24d9d
Queries are being ignored in user retrieval, causing all users to be retrieved and push parsing to fail. Query being ignored:
git-proxy/src/db/file/users.js
Lines 78 to 81 in 5d24d9d
(note that query is not passed in on last nline)
Push parsing that requires DB filtering of users that is not happening:
git-proxy/src/proxy/processors/push-action/checkUserPushPermission.js
Lines 13 to 20 in 5d24d9d
(note exactly one user must be found on line 17 - yet we are not actually filtering users)
The implementation does not merge records on update, but replaces them. This causes fields not supplied in the update to be dropped (e.g. if a user is updated on login via an SSO integration, then the Github user name is dropped as that is manually entered later).
git-proxy/src/db/file/users.js
Lines 65 to 76 in 5d24d9d
(this looks correct by @seald/nedb does not actually merge records when called like this - it finds the existing record and replaces it with the
user
passed in. This needs rewriting to either use the $set keyword or to manually retrieve the existing doc and merge into before callingdb.update
.neDB implementations should be set to compact their data files periodically, unless they are restarted regularly (compacts on read) - neDB uses an append-only file format so it will create many duplicate lines, See https://github.com/seald/nedb?tab=readme-ov-file#persistence. Add calls to set-up compaction to avoid infinite growth and very redundant data files.
No indexes are applied, which will result in performance losses as the dataset grows. Add calls to create indexes supporting common queries - these calls should be made on every start-up. See: https://github.com/seald/nedb?tab=readme-ov-file#indexing for details
Expected behavior
The behaviour of the file-based DB support should match that of the mongo implementation and it should work out-of-the-box.
Additional context
I'll raise a PR to address these issues in the implementation.
The text was updated successfully, but these errors were encountered: