Fix custom command creation constraint violation

Exclude 'creator' nested object from model_dump when creating custom commands.
The issue was that Pydantic was including both creator_id and creator fields,
causing Peewee to receive a nested dict that resulted in NULL creator_id values
in the database insert, violating the NOT NULL constraint.

This fix ensures only creator_id is passed to the ORM for foreign key mapping.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2025-11-14 08:09:44 -06:00
parent 78a6993204
commit d9ca88c1c8

View File

@ -368,7 +368,7 @@ async def create_custom_command_endpoint(
raise HTTPException(status_code=409, detail=f"Command '{command.name}' already exists")
# Create the command
command_data = command.model_dump(exclude={'id'})
command_data = command.model_dump(exclude={'id', 'creator'})
command_id = create_custom_command(command_data)
# Update creator stats