Skip to content

Bug: CLI "project update" fails with 400 Bad Request due to partial payload #2231

Description

@LevinCeglie

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

  1. Run the CLI command to update just the description of a project:
    klein project update -p "testproject" -d "new description"
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions