boxine/django-huey-monitor

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

Skrattoune opened this issue · 2 comments

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,
        )
jedie commented

I thinks the length cut of the description should be made in user code, where you create ProcessInfo...

Because a error like "Data too long for column 'desc' at row 1" is confusing, i add a check here: #29

The problem is that ProcessInfo use .update() that will not validate anything. So it happend this "low level" database error...

jedie commented

@Skrattoune it's released in v0.4.1