Skip to content
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

Error while deleting a group through the API call #16954

Open
rmjstn opened this issue Mar 20, 2020 · 19 comments · May be fixed by #34909
Open

Error while deleting a group through the API call #16954

rmjstn opened this issue Mar 20, 2020 · 19 comments · May be fixed by #34909
Labels
feat: api stat: triaged Issue reviewed and properly tagged

Comments

@rmjstn
Copy link

rmjstn commented Mar 20, 2020

Hello,

A user with Admin role.
Get all the groups with the API call : "groups.listAll".
The API method "groups.delete" return the bellow error when I call it by passing in parameter one of the ID get by the previous call.
{"success":false,"error":"The required "roomId" or "roomName" param provided does not match any group [error-room-not-found]","errorType":"error-room-not-found"}

Rocket version : 3.0.4.

Thanks,

Rémy

@rmjstn rmjstn changed the title Error while deleting a group throught the API call Error while deleting a group through the API call Mar 20, 2020
@Rodriq
Copy link
Contributor

Rodriq commented Mar 21, 2020

Hello,

A user with Admin role.
Get all the groups with the API call : "groups.listAll".
The API method "groups.delete" return the bellow error when I call it by passing in parameter one of the ID get by the previous call.
{"success":false,"error":"The required "roomId" or "roomName" param provided does not match any group [error-room-not-found]","errorType":"error-room-not-found"}

Rocket version : 3.0.4.

Thanks,

Rémy

Check your error message very well. I've tried the same API call and it works with roomId and roomName. Maybe you're missing something.
Remember the payload you're passing is suppose to be in a correct parsed JSON format. :)

@rmjstn
Copy link
Author

rmjstn commented Mar 21, 2020

Hello Rodriq,

This is an extract of my Python script.

The first call :

response=requests.get(ROCKET_URL + "groups.listAll?count=0", headers={'Content-Type':'application/json', 'X-Auth-Token':authentification["auth_token"], 'X-User-Id':authentification["user_id"]})

The second one :

data = {"roomId": group["id"]}
response=requests.post(ROCKET_URL + "groups.delete", data=json.dumps(data), headers={'Content-Type':'application/json', 'X-Auth-Token':authentification["auth_token"], 'X-User-Id':authentification["user_id"]})

It seems all right to me

Thanks,

Rémy

@Rodriq
Copy link
Contributor

Rodriq commented Mar 21, 2020

Hello Rodriq,

This is an extract of my Python script.

The first call :

response=requests.get(ROCKET_URL + "groups.listAll?count=0", headers={'Content-Type':'application/json', 'X-Auth-Token':authentification["auth_token"], 'X-User-Id':authentification["user_id"]})

The second one :

data = {"roomId": group["id"]}
response=requests.post(ROCKET_URL + "groups.delete", data=json.dumps(data), headers={'Content-Type':'application/json', 'X-Auth-Token':authentification["auth_token"], 'X-User-Id':authentification["user_id"]})

It seems all right to me

Thanks,

Rémy

Does the first response give an _id or id?

@rmjstn
Copy link
Author

rmjstn commented Mar 21, 2020

Rodriq,

An extract of the response of the first call :

{
	"groups": [{
			"_id": "6uuorMQ9zQj4AmQ3n",
			"name": "****",
			"fname": "****",
			"t": "p",
			"msgs": 4,
			"usersCount": 3,
			"u": {
				"_id": "Po6wYRakGP7kRsQHz",
				"username": "******"
			},
			"customFields": {},
			"broadcast": false,
			"ts": "2018-08-10T09:15:56.929Z",
			"ro": false,
			"default": false,
			"_updatedAt": "2020-02-17T05:02:02.830Z",
			"lm": "2018-08-10T09:28:19.973Z"
		},
                ...
		}, {
			"_id": "nvwHguBiReFCqeWzy",
			"name": "****",
			"fname": "****",
			"t": "p",
			"msgs": 10,
			"usersCount": 4,
			"u": {
				"_id": "ME7gyaiHWhiG22pGY",
				"username": "****"
			},
			"customFields": {},
			"broadcast": false,
			"encrypted": false,
			"ts": "2019-02-01T13:12:06.280Z",
			"ro": false,
			"default": false,
			"_updatedAt": "2020-02-17T05:02:02.830Z",
			"lm": "2019-02-01T13:32:48.506Z"
		}, {
data = {"roomId": group["id"]}
response=requests.post(ROCKET_URL + "groups.delete", data=json.dumps(data), headers={'Content-Type':'application/json', 'X-Auth-Token':authentification["auth_token"], 'X-User-Id':authentification["user_id"]})
print(response.text)
print(response.request.headers)
print(response.request.body)
{"success":false,"error":"The required \"roomId\" or \"roomName\" param provided does not match any group [error-room-not-found]","errorType":"error-room-not-found"}
{'User-Agent': 'python-requests/2.20.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'X-Auth-Token': '****', 'X-User-Id': '****', 'Content-Length': '31'}
{"roomId": "nvwHguBiReFCqeWzy"}

If I pass the roomName instead of the roomId, I've got the same error.

Rémy

@rmjstn
Copy link
Author

rmjstn commented Mar 21, 2020

Here are the logs. But I don't think it provides more informations.

I20200321-22:48:06.291(0) server.js:204 API ➔ debug POST: /api/v1/login 
I20200321-22:48:06.586(0) server.js:204 API ➔ debug GET: /api/v1/groups.listAll?count=0 
I20200321-22:48:06.703(0) server.js:204 API ➔ debug Success {   statusCode: 200,   body: {     groups: [       [Object], [Object], [Object], [Object], [Object], [Object],       [Object], [Object], [Object], [Object], [Object], [Object],     [Object], [Object], [Object], [Object],       ... 150 more items     ],     offset: 0,     count: 250,     total: 250,     success: true   } } 
I20200321-22:48:06.924(0) server.js:204 API ➔ debug POST: /api/v1/login 
I20200321-22:48:07.226(0) server.js:204 API ➔ debug POST: /api/v1/groups.delete 
I20200321-22:48:07.232(0) server.js:204 API ➔ debug post groups.delete threw an error: Error: The required "roomId" or "roomName" param provided does not match any group [error-room-not-found]     at findPrivateGroupByIdOrName (app/api/server/v1/groups.js:37:9)     at Object.post (app/api/server/v1/groups.js:241:22)     at app/api/server/api.js:343:82     at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1234:12)     at Object._internalRouteActionHandler [as action] (app/api/server/api.js:343:39)     at Route.share.Route.Route._callEndpoint (packages/nimble_restivus/lib/route.coffee:150:32)     at packages/nimble_restivus/lib/route.coffee:59:33     at packages/simple_json-routes.js:98:9 
I20200321-22:48:07.233(0) server.js:204 API ➔ debug Failure {   statusCode: 400,   body: {     success: false,     error: 'The required "roomId" or "roomName" param provided does not match any group [error-room-not-found]',     stack: undefined,     errorType: 'error-room-not-found'   } } 

@Rodriq
Copy link
Contributor

Rodriq commented Mar 22, 2020

Rodriq,

An extract of the response of the first call :

{
	"groups": [{
			"_id": "6uuorMQ9zQj4AmQ3n",
			"name": "****",
			"fname": "****",
			"t": "p",
			"msgs": 4,
			"usersCount": 3,
			"u": {
				"_id": "Po6wYRakGP7kRsQHz",
				"username": "******"
			},
			"customFields": {},
			"broadcast": false,
			"ts": "2018-08-10T09:15:56.929Z",
			"ro": false,
			"default": false,
			"_updatedAt": "2020-02-17T05:02:02.830Z",
			"lm": "2018-08-10T09:28:19.973Z"
		},
                ...
		}, {
			"_id": "nvwHguBiReFCqeWzy",
			"name": "****",
			"fname": "****",
			"t": "p",
			"msgs": 10,
			"usersCount": 4,
			"u": {
				"_id": "ME7gyaiHWhiG22pGY",
				"username": "****"
			},
			"customFields": {},
			"broadcast": false,
			"encrypted": false,
			"ts": "2019-02-01T13:12:06.280Z",
			"ro": false,
			"default": false,
			"_updatedAt": "2020-02-17T05:02:02.830Z",
			"lm": "2019-02-01T13:32:48.506Z"
		}, {
data = {"roomId": group["id"]}
response=requests.post(ROCKET_URL + "groups.delete", data=json.dumps(data), headers={'Content-Type':'application/json', 'X-Auth-Token':authentification["auth_token"], 'X-User-Id':authentification["user_id"]})
print(response.text)
print(response.request.headers)
print(response.request.body)
{"success":false,"error":"The required \"roomId\" or \"roomName\" param provided does not match any group [error-room-not-found]","errorType":"error-room-not-found"}
{'User-Agent': 'python-requests/2.20.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'X-Auth-Token': '****', 'X-User-Id': '****', 'Content-Length': '31'}
{"roomId": "nvwHguBiReFCqeWzy"}

If I pass the roomName instead of the roomId, I've got the same error.

Rémy
Where exactly did you specify the groups variable that you are using in your data.
From the first get call, you may want to do something like response.json()["groups"][0]["_id"] to get the _id of the first group.

Check your logic very well. I don't think it has to do that much with the server.

@rmjstn
Copy link
Author

rmjstn commented Mar 23, 2020

Hello,

The API method groups.counters works, but not the method groups.info !!!???

With this Python script :

1 -
response=requests.get(ROCKET_URL + "groups.counters?roomId=" + group["id"], headers={'Content-Type':'application/json', 'X-Auth-Token':authentification["auth_token"], 'X-User-Id':authentification["user_id"]})
print(response.request.url)
print(response.text)
2 -
response=requests.get(ROCKET_URL + "groups.info?roomId=" + group["id"], headers={'Content-Type':'application/json', 'X-Auth-Token':authentification["auth_token"], 'X-User-Id':authentification["user_id"]})
print(response.request.url)    
print(response.text)
3 -
data = {"roomId": group["id"]}
response=requests.post(ROCKET_URL + "groups.delete", data=json.dumps(data), headers={'Content-Type':'application/json', 'X-Auth-Token':authentification["auth_token"], 'X-User-Id':authentification["user_id"]})
print(response.request.url)   
print(response.text)
print(response.request.headers)
print(response.request.body)

I've got this output :

1 -
https://rocket.***/api/v1/groups.counters?roomId=nvwHguBiReFCqeWzy
{"joined":false,"members":4,"unreads":null,"unreadsFrom":null,"msgs":10,"latest":"2019-02-01T13:32:48.506Z","userMentions":null,"success":true}
2 -
https://rocket.***/api/v1/groups.info?roomId=nvwHguBiReFCqeWzy
{"success":false,"error":"The required \"roomId\" or \"roomName\" param provided does not match any group [error-room-not-found]","errorType":"error-room-not-found"}
3 -
https://rocket.***/api/v1/groups.delete
{"success":false,"error":"The required \"roomId\" or \"roomName\" param provided does not match any group [error-room-not-found]","errorType":"error-room-not-found"}
{'User-Agent': 'python-requests/2.20.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'X-Auth-Token': '***', 'X-User-Id': '***', 'Content-Length': '31'}
{"roomId": "nvwHguBiReFCqeWzy"}

Thanks,

Rémy

@gabriellsh
Copy link
Member

@rmjstn Did you solve your previous problem?

@rmjstn
Copy link
Author

rmjstn commented Mar 25, 2020

@gabriellsh

No, :-(

Rémy

@gabriellsh
Copy link
Member

Does the user you're using in the api calls have the permission to see private rooms or delete rooms? Usually that's the error when you try to open a room you have no permission to see. (assuming rid is correct)

@Beeez
Copy link

Beeez commented May 1, 2020

I am attempting to do similar. I have Admin role and it fails when I try and delete the room. I am not a member of the room I am attempting to delete.

Once I was added to the room I was able to delete it.

Admin role does have Delete Private Channels and View Private Room as a permission which my user is a part of.

/api/v1/groups.delete

{"success":false,"error":"The required \"roomId\" or \"roomName\" param provided does not match any channel [error-room-not-found]","errorType":"error-room-not-found"}

@Beeez
Copy link

Beeez commented May 4, 2020

Does the user you're using in the api calls have the permission to see private rooms or delete rooms? Usually that's the error when you try to open a room you have no permission to see. (assuming rid is correct)

Not OP but I had tested this on both 3.0.3 and 3.2.0 and both of them will not allow admins to use to groups.delete API endpoint unless they are a member of that group.

@Beeez
Copy link

Beeez commented May 18, 2020

gabriellsh added the feat: api label on Mar 25

Is this really a feature? The feature exists but its bugged, so it should be marked as such.

@gabriellsh
Copy link
Member

The tag serves as an indicator to what feature it's related (at least I use them as if they were).

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stat: stale Stale issues will be automatically closed if no activity label Jul 18, 2020
@Beeez
Copy link

Beeez commented Jul 20, 2020

Still an active issue with the groups.delete API Endpoint

@github-actions github-actions bot removed the stat: stale Stale issues will be automatically closed if no activity label Jul 21, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Oct 7, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stat: stale Stale issues will be automatically closed if no activity label Oct 7, 2020
@gabriellsh gabriellsh removed the stat: stale Stale issues will be automatically closed if no activity label Oct 7, 2020
@nafil-gigsboard
Copy link

I am also hitting the same. Any fix for this. My admin have to delete some private rooms from rest api.
Having permissions for admin.
Same for room details update. Admin can't update room details from rest api.

Can you please deploy a fix urgently

@dougfabris dougfabris added the stat: triaged Issue reviewed and properly tagged label Oct 11, 2021
@sudhir-sars
Copy link

sudhir-sars commented Jan 8, 2025

I was able to reproduce the issue where the API call fails when the admin is not part of the private group. Here are the two scenarios I tested:

When the admin is not part of the private group:
image
and When the admin is part of the group:
image

I am currently working on resolving this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: api stat: triaged Issue reviewed and properly tagged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants