Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Skrattoune opened this issue May 29, 2021 · 2 comments
Closed

Comments

@Skrattoune
Copy link
Contributor

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 pushed a commit that referenced this issue May 31, 2021
@jedie
Copy link
Collaborator

jedie commented May 31, 2021

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 jedie closed this as completed May 31, 2021
jedie pushed a commit that referenced this issue May 31, 2021
phihag added a commit that referenced this issue May 31, 2021
 Fix #27 Data too long for column 'desc'
@jedie
Copy link
Collaborator

jedie commented Jun 2, 2021

@Skrattoune it's released in v0.4.1

Skrattoune added a commit to Skrattoune/django-huey-monitor that referenced this issue Mar 24, 2022
Coming back to boxine#27,
I had in a middle of a long series of tasks one of them which crashed due to a ValidationError('Process info description overlong').

It reminded me about boxine#27 where I thought we implemented a crop of TaskModel.desc to 64 characters.

As stated already at the time. having a desc bigger than 64 char should not for me prevent a task to run.
Especially when task description are generated automatically

I would therefore suggest implementing the following changes
Skrattoune added a commit to Skrattoune/django-huey-monitor that referenced this issue Mar 30, 2022
Skrattoune added a commit to Skrattoune/django-huey-monitor that referenced this issue Mar 30, 2022
Skrattoune added a commit to Skrattoune/django-huey-monitor that referenced this issue Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants