semaphoreui / semaphore

Modern UI and powerful API for Ansible, Terraform, OpenTofu, PowerShell and other DevOps tools.
https://semaphoreui.com
MIT License
10.65k stars 1.07k forks source link

Status Code 400 on Linking New Team Member to Project #1335

Open viiwee opened 1 year ago

viiwee commented 1 year ago

I'm on v2.8.91. When trying to link a team member to a project, I receive an error "Request failed with status code 400". I was previously on v2.8.51, but upgraded today.

image.

No logs are generated by the Semaphore process. My temporary fix was to modify the database directly and link the user to the project. But I think there may be an issue with the API on this button click.

Other info:

viiwee commented 1 year ago

After reverting to v2.8.90, the error went away. I had to roll back the DB structure first to remove the new role column, but that seemed to work for now.

ALTER TABLE project__user ADD `admin` BOOLEAN NOT NULL DEFAULT FALSE;
ALTER TABLE project__user DROP `role`;
UPDATE project__user SET admin = true WHERE user_id = 2;
rsandj commented 1 year ago

I see the same also on v2.8.91. I have not configured any LDAP og email. I added a user, but when trying to add the user to a team in a project, I get the same "Request failes with status code 400" as shown in the screenshot above. I have done a first time install of Semaphore.

Arkhenys commented 1 year ago

This is because roles have been added. You can view it using the API. Try a get on project's users. You will still see "admin": true (or false) but "role": "owner" (or "task_runner") has also been added.

You can still link a user to a project using the API and using the "role" key with the desired value. But it appears that from the GUI, the request is not implemented with the requested "role" key.

makorolkov commented 1 year ago

Bypassed this problem this way INSERT INTO project__user(project_id,user_id,role) VALUES(1,2,'owner'); Where user_id user we add to teams

ansibleguy commented 1 year ago

Just linking: Issue seems to be related to https://github.com/ansible-semaphore/semaphore/pull/1322

fiftin commented 1 year ago

Hi all, thank you! Will fix soon.

fiftin commented 1 year ago

hi @viiwee ,

Did you fix the issue? Do you have access to database?

It is my mistake to make task_runner default role for non-admin users :) It should be manager.

fiftin commented 1 year ago

The issue can be easily fixed by updating roles in database:

update project__user set role = 'manager' where role = 'task_runner';
viiwee commented 1 year ago

hi @viiwee ,

Did you fix the issue? Do you have access to database?

It is my mistake to make task_runner default role for non-admin users :) It should be manager.

I didn't test the fix on v2.8.91, I reverted back to v2.8.90 instead. It looks like your fix should work though.

Thanks for the updates!

viiwee commented 1 year ago

Oops, did not mean to close the issue.

kbzowski commented 1 year ago

Is 2.8.92 safe to upgrade?

steadfasterX commented 1 year ago

I still have that issue on a fresh v2.8.92 installation @fiftin . also using LDAP if that matters but I changed back to local and the issue remains.

that previous mentioned wrong role seems to be solved though :

MariaDB [semaphore]> select * from project__user;

+------------+---------+-------+
| project_id | user_id | role  |
+------------+---------+-------+
|          1 |       2 | owner |
|          2 |       4 | owner |
+------------+---------+-------+

the previous mentioned cmd

INSERT INTO project__user(project_id,user_id,role) VALUES(1,3,'owner');

works fine as a workaround though.

also:

is both working fine!

PS: there is a typo in the manager role: image

changchichung commented 1 year ago

I have the exact same issue, but I'm not using psql/mysql. Below is my docker-compose.yml. How should I address this problem?

services:
  semaphore:
    ports:
      - 806:3000
    image: semaphoreui/semaphore:latest
    environment:
      SEMAPHORE_DB_DIALECT: bolt
      SEMAPHORE_ADMIN_PASSWORD: adminpassword
      SEMAPHORE_ADMIN_NAME: admin
      SEMAPHORE_ADMIN_EMAIL: sa@abc.com
      SEMAPHORE_ADMIN: admin
    volumes:
      - ./semaphore:/etc/semaphore # config.json location
      - ./db:/var/lib/semaphore # database.boltdb location (Not required if using mysql or postgres)
      - ./resolv.conf:/etc/resolv.conf
nobilisgkill4 commented 1 year ago

Same here.

Running a docker compose with postgres:14 and semaphoreui/semaphore:latest

gaeldb commented 1 year ago

Hi all,

I'm on 2.8.91 and experiment the same problem.

Just need to update the POST request with a role paramater and new team member get added:

{"user_id":4,"project_id":1,"role":"manager"}

I can provide a PR. In my comprehension, this is needed:

gaeldb commented 1 year ago

Fixed with 2.9.4 Thank you