Skip to content

Implement validator for TaskModel.desc field or crop to 64 char? #27

@Skrattoune

Description

@Skrattoune

Hi,
I had a strange error error - (1406, "Data too long for column 'desc' at row 1")
After browsing the net, and then exploring the code of huey-monitor,

I finally manage to realize the reason my task was failling was that the description I was setting for my ProcessInfo was 67 char while only 64 were authorized by the TaskModel model.

This error was quite small, and may happen easily ... but it was quite hard to find-out.

I therefore would suggest to make this error much more easy to find-out for users.

One solution could be to implement a custom validator for the TaskModel.desc field to document specifically the error for the user.

However, having a desc bigger than 64 char should not for me prevent a task to run.
I would therefore suggest another simpler solution:
to implement in the ProcessInfo model a crop to 64 char when updating TaskModel.

A minimal implementation could be:

TaskModel.objects.filter(task_id=task.id).update(
            desc=self.desc[:64],
            total=self.total,
            unit=self.unit,
            unit_divisor=self.unit_divisor,
        )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions