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

Report detailed error messages on task update and delete #618

Merged
merged 4 commits into from
Mar 8, 2023

Conversation

jaragunde
Copy link
Member

I'm increasing the error reporting for task update and delete operations, and also making some changes in the front-end to make error messages more noticeable; I'm afraid that users have become accustomed to ignore them.

@jaragunde jaragunde force-pushed the task-error-messages-update-delete branch 3 times, most recently from b1eb1e7 to 148f3d7 Compare March 6, 2023 10:54
@jaragunde
Copy link
Member Author

I've just fixed some copy-paste in error messages but this is ready to review, I'm not working more on it.

Copy link
Member

@anarute anarute left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added some minor comments, testing locally it works fine! Thank you

}
$result->setMessage($resultMessage);
$result->setIsSuccessful(false);
$result->setResponseCode(500);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we've been using 500 everywhere but I wonder if it shouldn't be 400 in this case, what do you think? Here and in the other places where the request fails because the user sent a bad input.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now you mention, most errors would fall under the "bad request" or "forbidden" umbrellas so it makes sense to review them all...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of trying to be more specific with the http result code when we can.

if ($taskDao->batchPartialUpdate($this->tasks) < count($this->tasks)) {
return -1;
}
$results = $taskDao->batchPartialUpdate($this->tasks);

//TODO: do something meaningful with the list of discarded tasks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think with your changes we can remove this comment? :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, we don't match the errors with the discarded tasks, so we don't report the client which tasks were successfully created and which weren't...

I'm not sure if we'll ever want to do that, it would increase the client complexity quite a lot.

if ($res == NULL) throw new SQLQueryErrorException(pg_last_error());
$affectedRows = pg_affected_rows($res);
$result->setIsSuccessful(true);
$result->setMessage('Project deleted successfully.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant Task deleted successfully.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the string of copy-paste errors never ends :)

if (!$projectVO || !$projectVO->getActivation()) {
$result = new OperationResult(false);
$result->setErrorNumber(30);
$result->setResponseCode(500);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe 403 here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Collaborator

@dmtrek14 dmtrek14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than one small nit (which could be addressed later), I think this looks good. Thanks for getting the detailed error messages implemented for tasks - this is a huge improvement.

We build an OperationResult for every situation where a task update is
denied, and we also capture SQL exceptions and wrap them in
OperationResult objects.
The DAO operation is also ported to PDO, addressing #513.
Make "error" font red, add an icon next to it and increase message
time on screen.
Web services return the code contained in the first OperationResult.
Codes have been reviewed to use 400 (bad request) and 403 (forbidden)
instead of 500 when they make more sense, which is most known error
cases.
@jaragunde jaragunde force-pushed the task-error-messages-update-delete branch from 148f3d7 to a89be33 Compare March 7, 2023 10:46
Copy link
Member Author

@jaragunde jaragunde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've submitted a new patch set amending the existing patches to address your comments. In a new patch I've reviewed all the error codes related to task create, update and delete and make web services pass them instead of using always 500.

}
$result->setMessage($resultMessage);
$result->setIsSuccessful(false);
$result->setResponseCode(500);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now you mention, most errors would fall under the "bad request" or "forbidden" umbrellas so it makes sense to review them all...

if ($taskDao->batchPartialUpdate($this->tasks) < count($this->tasks)) {
return -1;
}
$results = $taskDao->batchPartialUpdate($this->tasks);

//TODO: do something meaningful with the list of discarded tasks
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, we don't match the errors with the discarded tasks, so we don't report the client which tasks were successfully created and which weren't...

I'm not sure if we'll ever want to do that, it would increase the client complexity quite a lot.

if ($res == NULL) throw new SQLQueryErrorException(pg_last_error());
$affectedRows = pg_affected_rows($res);
$result->setIsSuccessful(true);
$result->setMessage('Project deleted successfully.');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the string of copy-paste errors never ends :)

web/include/phpreport.css Show resolved Hide resolved
if (!$projectVO || !$projectVO->getActivation()) {
$result = new OperationResult(false);
$result->setErrorNumber(30);
$result->setResponseCode(500);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jaragunde
Copy link
Member Author

Thanks for your reviews! I understand it can be merged already.

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

Successfully merging this pull request may close these issues.

3 participants