Skip to content

[Bug]: Internal Server Error when updating a nonexistent user #3383

@jvstme

Description

@jvstme

Steps to reproduce

$ curl -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" --request POST --data '{"username": "nonexistent", "global_role": "user"}' http://localhost:3000/api/users/update

Actual behaviour

Internal Server Error

Expected behaviour

{"detail":[{"msg":"Resource not found","code":"resource_not_exists"}]}

dstack version

master

Server logs

File "/dstack/src/dstack/_internal/server/routers/users.py", line 87, in update_user
    res = await users.update_user(
  File "/dstack/src/dstack/_internal/server/services/users.py", line 144, in update_user
    return await get_user_model_by_name_or_error(session=session, username=username)
  File "/dstack/src/dstack/_internal/server/services/users.py", line 255, in get_user_model_by_name_or_error
    return get_or_error(
  File "/dstack/src/dstack/_internal/utils/common.py", line 270, in get_or_error
    raise ValueError("Optional value is None")
ValueError: Optional value is None

Additional information

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingminor

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions