datahuborg / datahub

An experimental hosted platform (GitHub-like) for organizing, managing, sharing, collaborating, and making sense of data.
https://datahub.csail.mit.edu
MIT License
210 stars 60 forks source link

I could add user "test" as a collaborator but could not delete it #210

Open clouds56 opened 7 years ago

clouds56 commented 7 years ago

When I add some user that not exist like "test1", it would complain "User matching query does not exist. 404 : DoesNotExist" While when I add the user "test",

POST /api/v1/repos/clouds56/hello/collaborators/
{
  "user": "test",
  "db_permissions": ["SELECT"],
  "file_permissions": ["read"]
}

HTTP 201 Created
Allow: GET, POST, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept
{
    "username": "test",
    "db_permissions": "U",
    "file_permissions": ""
}

it do succeed and the user test is list in Collaborators, Permissions:

GET /api/v1/repos/clouds56/hello/collaborators/test/

HTTP 200 OK
Allow: GET, DELETE, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept
{
    "username": "test",
    "db_permissions": "U",
    "file_permissions": ""
}

But when I tried to remove it

DELETE /api/v1/repos/clouds56/hello/collaborators/test/

HTTP 404 Not Found
Allow: GET, DELETE, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept
{
    "error_type": "DoesNotExist",
    "detail": "User matching query does not exist."
}

Why could this happen? (the demo steps above is shown by API, while manipulating it in the dashboard gets the same result) I could think of this scenario, I invited a user called "guest" to my repo, and after some while the user "guest" is deleted and (I don't know if it is possible) it remains in my repo's collaborators list, and I have no way to delete the "guest" user.

BTW, I think the api "GET /api/v1/repos/clouds56/hello/collaborators/1/" does not work as intended when it receives some user that not exists in the repo:

GET /api/v1/repos/clouds56/hello/collaborators/1/

HTTP 200 OK
Allow: GET, DELETE, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept
[
    {
        "username": "clouds56",
        "db_permissions": "UC",
        "file_permissions": ""
    },
    {
        "username": "test",
        "db_permissions": "U",
        "file_permissions": ""
    }
]

it should return 404 i think.