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

Error 500 when creating task with start time > end time #492

Closed
jaragunde opened this issue Feb 25, 2021 · 1 comment
Closed

Error 500 when creating task with start time > end time #492

jaragunde opened this issue Feb 25, 2021 · 1 comment

Comments

@jaragunde
Copy link
Member

jaragunde commented Feb 25, 2021

When a creation query with start time later than end time is issued, like this:

<?xml version="1.0" encoding="UTF-8"?>
<tasks>
  <task>
    <date>2021-2-25</date>
    <initTime>13:45</initTime>
    <endTime>13:15</endTime>
    <projectId>2</projectId>
  </task>
</tasks>

It will cause an internal server error and return an an error 500. The error message logged is:

PHP Fatal error:  Uncaught SQLQueryErrorException: ERROR:  23514: new row for relation "task" violates check constraint "end_after_init_task"
DETAIL:  Failing row contains (5, 2021-02-25, 825, 795, null, f, null, null, null, 4, 2, null, null, f).
SCHEMA NAME:  public
TABLE NAME:  task
CONSTRAINT NAME:  end_after_init_task
LOCATION:  ExecConstraints, execMain.c:2083 in /var/www/html/phpreport/model/dao/TaskDAO/PostgreSQLTaskDAO.php:932
Stack trace:
#0 /var/www/html/phpreport/model/dao/TaskDAO/PostgreSQLTaskDAO.php(950): PostgreSQLTaskDAO->create(Object(TaskVO))
#1 /var/www/html/phpreport/model/facade/action/CreateTasksAction.php(87): PostgreSQLTaskDAO->batchCreate(Array)
#2 /var/www/html/phpreport/model/facade/action/Action.php(112): CreateTasksAction->doExecute()
#3 /var/www/html/phpreport/model/facade/TasksFacade.php(103): Action->execute()
#4 /var/www/html/phpreport/web/services/createTasksService.php(230): TasksFacade::CreateReports(Array)
#5 {main}
  thrown in /var/www/html/phpreport/model/dao/TaskDAO/PostgreSQLTaskDAO.php on line 932

The backend should fail gracefully when trying to create tasks with incorrect data.

jaragunde added a commit that referenced this issue Feb 24, 2023
We capture SQL exceptions that could happen in task creation and
wrap them into an OperationResult to be returned by the web service.

Fixes #492 because it handles the situation that caused that error.
jaragunde added a commit that referenced this issue Feb 28, 2023
We capture SQL exceptions that could happen in task creation and
wrap them into an OperationResult to be returned by the web service.

Fixes #492 because it handles the situation that caused that error.
@jaragunde
Copy link
Member Author

Merged in #616:

f3f8c5f3 [#492, #496] Manage and return SQL errors on task creation. [Jacobo Aragunde Pérez]
00088a42 [#173] Allow to report multiple errors on the same creation batch. [Jacobo Aragunde Pérez]
f4700807 [#173] Report several kinds of errors on task creation. [Jacobo Aragunde Pérez]
a2a96ce8 Prevent calling task create without overlap check. [Jacobo Aragunde Pérez]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant