-
Notifications
You must be signed in to change notification settings - Fork 240
fix(api): Resource::list return empty list if the regex is not valid #8437
Conversation
->findResources($filter); | ||
} catch (\PDOException $e) { | ||
if ($e->getCode() !== "42000") { | ||
throw $e; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The controller must not be aware of structure exceptions.
PDO is a class to read data so it's not a business class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your repository can raised a specific exception that will can be catch by the service
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you give an example from the existing code base, because the idea isn't to change the behavior that we have already just to avoid the particular problem described in the PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
Resolve MON-5034
…erviceInterface ERROR: Call to an undefined method Centreon\Domain\Monitoring\Interfaces\ResourceServiceInterface::filterByContact() Resolve MON-5034
Resolve MON-5034
…face Resolve MON-5034
Resolve MON-5034
Resolve MON-5034
Resolve MON-5034
@@ -48,7 +48,7 @@ | |||
final class ResourceRepositoryRDB extends AbstractRepositoryDRB implements ResourceRepositoryInterface | |||
{ | |||
/** | |||
* @var AccessGroup[] List of access group used to filter the requests | |||
* @var AccessGroup[]|null List of access group used to filter the requests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
List can be emty, not null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it
src/Centreon/Infrastructure/RequestParameters/SqlRequestParametersTranslator.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@callapa please be more careful when you introduce a new code and be sure it's tested and at least it's working properly
Co-Authored-By: Laurent Calvet <lcalvet@centreon.com>
src/Centreon/Infrastructure/RequestParameters/SqlRequestParametersTranslator.php
Outdated
Show resolved
Hide resolved
…tersTranslator.php
Description
when the user sends invalid regexp to with operator $rg server will throw an exception from the DB,
the idea is to return empty list
related PR https://github.com/centreon/centreon/pull/8432
Fixes MON-5034
Type of change
Target serie
How this pull request can be tested ?
send GET request to http://localhost/centreon/api/beta/monitoring/resources?page=1&limit=100&search={%22$or%22:[{%22name%22:{%22$rg%22:%22a%22}}]}
Checklist
Community contributors & Centreon team
Centreon team only