Context
When attempting to update only a single field of a project (like the description) using the CLI, the command crashes with a 400 Bad Request from the backend.
Steps to Reproduce
- Run the CLI command to update just the description of a project:
klein project update -p "testproject" -d "new description"
- Observe the following HTTP 400 error trace:
HTTPStatusError: Client error '400 Bad Request' for url 'http://localhost:3000/projects/29b44a37-...
Root Cause
There is a mismatch between what the CLI sends and what the backend validation expects:
- CLI (routes.py): The
_update_project function does a partial update. It constructs a JSON body containing only the provided fields (e.g., {"description": "new descriptionsgad"}) and sends it via a PUT request.
- Backend (project.controller.ts): The
PUT /projects/:uuid route maps the incoming payload to the CreateProject DTO (create-project.dto.ts). This DTO uses class-validator decorators like @IsNotEmpty() on both name and description.
Because the CLI didn't send the name field, the backend validation pipeline rejects the request immediately.
Solutions
Option A is preferred, option B would be more of a quick fix. Note that the web frontend currently uses Option B. So after implementing Option A one would have to adjust the web frontend as well.
Option A:
Change the route to PATCH /projects/:uuid which accepts any non-empty partial updates, builds a full dto and runs it through the same validation as for creating new projcets.
Option B:
The CLI first issues a GET request to fetch the existing project values, merge the updated fields locally, and send the full payload (name and description) back in the PUT request.
Context
When attempting to update only a single field of a project (like the description) using the CLI, the command crashes with a
400 Bad Requestfrom the backend.Steps to Reproduce
Root Cause
There is a mismatch between what the CLI sends and what the backend validation expects:
_update_projectfunction does a partial update. It constructs a JSON body containing only the provided fields (e.g.,{"description": "new descriptionsgad"}) and sends it via aPUTrequest.PUT /projects/:uuidroute maps the incoming payload to theCreateProjectDTO (create-project.dto.ts). This DTO usesclass-validatordecorators like@IsNotEmpty()on bothnameanddescription.Because the CLI didn't send the
namefield, the backend validation pipeline rejects the request immediately.Solutions
Option A is preferred, option B would be more of a quick fix. Note that the web frontend currently uses Option B. So after implementing Option A one would have to adjust the web frontend as well.
Option A:
Change the route to
PATCH /projects/:uuidwhich accepts any non-empty partial updates, builds a full dto and runs it through the same validation as for creating new projcets.Option B:
The CLI first issues a
GETrequest to fetch the existing project values, merge the updated fields locally, and send the full payload (nameanddescription) back in thePUTrequest.