Fix an eventual 500 error on duplicate planning update
mRoca opened this issue · 2 comments
mRoca commented
Detected in production:
{
"message": "Uncaught PHP Exception Symfony\\Component\\HttpKernel\\Exception\\BadRequestHttpException: \"An exception occurred while executing 'INSERT INTO user_availability (id, start_time, end_time, status, booked_at, created_at, updated_at, user_id, planning_agent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)' with params [39635, \"2020-04-04 10:00:00+0000\", \"2020-04-04 12:00:00+0000\", \"booked\", \"2020-04-03 08:50:23+0000\", \"2020-04-03 08:50:23+0000\", \"2020-04-03 08:50:23+0000\", 446, 1]:\n\nSQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint \"user_availability_slot_unique\"\nDETAIL: Key (user_id, start_time, end_time)=(446, 2020-04-04 10:00:00+00, 2020-04-04 12:00:00+00) already exists.\" at /srv/src/Controller/Organization/Planning/PlanningUpdateController.php line 64",
"context": {
"exception": {
"class": "Symfony\\Component\\HttpKernel\\Exception\\BadRequestHttpException",
"message": "An exception occurred while executing 'INSERT INTO user_availability (id, start_time, end_time, status, booked_at, created_at, updated_at, user_id, planning_agent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)' with params [39635, \"2020-04-04 10:00:00+0000\", \"2020-04-04 12:00:00+0000\", \"booked\", \"2020-04-03 08:50:23+0000\", \"2020-04-03 08:50:23+0000\", \"2020-04-03 08:50:23+0000\", 446, 1]:\n\nSQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint \"user_availability_slot_unique\"\nDETAIL: Key (user_id, start_time, end_time)=(446, 2020-04-04 10:00:00+00, 2020-04-04 12:00:00+00) already exists.",
"code": 0,
"file": "/srv/src/Controller/Organization/Planning/PlanningUpdateController.php:64",
"previous": {
"class": "Doctrine\\DBAL\\Exception\\UniqueConstraintViolationException",
"message": "An exception occurred while executing 'INSERT INTO user_availability (id, start_time, end_time, status, booked_at, created_at, updated_at, user_id, planning_agent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)' with params [39635, \"2020-04-04 10:00:00+0000\", \"2020-04-04 12:00:00+0000\", \"booked\", \"2020-04-03 08:50:23+0000\", \"2020-04-03 08:50:23+0000\", \"2020-04-03 08:50:23+0000\", 446, 1]:\n\nSQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint \"user_availability_slot_unique\"\nDETAIL: Key (user_id, start_time, end_time)=(446, 2020-04-04 10:00:00+00, 2020-04-04 12:00:00+00) already exists.",
"code": 0,
"file": "/srv/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php:51",
"trace": [
"/srv/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:166",
"/srv/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:146",
"/srv/vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php:162",
"/srv/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:287",
"/srv/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:1087",
"/srv/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:400",
"/srv/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:368",
"/srv/src/Domain/PlanningUpdateDomain.php:98",
"/srv/src/Controller/Organization/Planning/PlanningUpdateController.php:62",
"/srv/vendor/symfony/http-kernel/HttpKernel.php:157",
"/srv/vendor/symfony/http-kernel/HttpKernel.php:79",
"/srv/vendor/symfony/http-kernel/Kernel.php:191",
"/srv/public/index.php:27"
],
"previous": {
"class": "Doctrine\\DBAL\\Driver\\PDOException",
"message": "SQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint \"user_availability_slot_unique\"\nDETAIL: Key (user_id, start_time, end_time)=(446, 2020-04-04 10:00:00+00, 2020-04-04 12:00:00+00) already exists.",
"code": 23505,
"file": "/srv/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:123",
"trace": [
"/srv/vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php:153",
"/srv/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:287",
"/srv/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:1087",
"/srv/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:400",
"/srv/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:368",
"/srv/src/Domain/PlanningUpdateDomain.php:98",
"/srv/src/Controller/Organization/Planning/PlanningUpdateController.php:62",
"/srv/vendor/symfony/http-kernel/HttpKernel.php:157",
"/srv/vendor/symfony/http-kernel/HttpKernel.php:79",
"/srv/vendor/symfony/http-kernel/Kernel.php:191",
"/srv/public/index.php:27"
],
"previous": {
"class": "PDOException",
"message": "SQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint \"user_availability_slot_unique\"\nDETAIL: Key (user_id, start_time, end_time)=(446, 2020-04-04 10:00:00+00, 2020-04-04 12:00:00+00) already exists.",
"code": 23505,
"file": "/srv/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:121",
"trace": [
"/srv/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:121",
"/srv/vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php:153",
"/srv/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:287",
"/srv/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:1087",
"/srv/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:400",
"/srv/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:368",
"/srv/src/Domain/PlanningUpdateDomain.php:98",
"/srv/src/Controller/Organization/Planning/PlanningUpdateController.php:62",
"/srv/vendor/symfony/http-kernel/HttpKernel.php:157",
"/srv/vendor/symfony/http-kernel/HttpKernel.php:79",
"/srv/vendor/symfony/http-kernel/Kernel.php:191",
"/srv/public/index.php:27"
]
}
}
},
"trace_string": "[\"/srv/vendor/symfony/http-kernel/HttpKernel.php:157\",\"/srv/vendor/symfony/http-kernel/HttpKernel.php:79\",\"/srv/vendor/symfony/http-kernel/Kernel.php:191\",\"/srv/public/index.php:27\"]"
},
"error": "Uncaught PHP Exception Symfony\\Component\\HttpKernel\\Exception\\BadRequestHttpException: \"An exception occurred while executing 'INSERT INTO user_availability (id, start_time, end_time, status, booked_at, created_at, updated_at, user_id, planning_agent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)' with params [39635, \"2020-04-04 10:00:00+0000\", \"2020-04-04 12:00:00+0000\", \"booked\", \"2020-04-03 08:50:23+0000\", \"2020-04-03 08:50:23+0000\", \"2020-04-03 08:50:23+0000\", 446, 1]:\n\nSQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint \"user_availability_slot_unique\"\nDETAIL: Key (user_id, start_time, end_time)=(446, 2020-04-04 10:00:00+00, 2020-04-04 12:00:00+00) already exists.\" at /srv/src/Controller/Organization/Planning/PlanningUpdateController.php line 64"
},
"level": 400,
"level_name": "ERROR",
"channel": "request",
"datetime": "2020-04-03T08:50:23+00:00",
"extra": {
"request_id": "ng-ffe9c8520d5dfadc9557d8150939804e"
}
}
mRoca commented
mRoca commented