passbolt/passbolt_api · error · BadRequestException
Could not delete favorite.
Error message
Could not delete favorite.
What it means
FavoritesDeleteService throws this BadRequestException (HTTP 400) when the delete produced validation errors that are NOT the ownership rule — i.e. an unexpected entity-level validation failure blocked the deletion of the favorite.
Solutions
- Inspect the response body for the errors payload to identify the failing rule
- Run migrations (`ddev refresh`) to ensure schema matches the code expectations
- Reproduce locally and log $favorite->getErrors() after delete to see the concrete rule
- Check for customization in the Favorites table model rules
Defensive patterns
Strategy: try-catch
Try / catch
try {
await api.delete(`/favorites/${id}`);
} catch (e) {
if (e.response?.status === 400) {
console.error('Delete blocked, server errors:', e.response?.body || e.response?.data);
}
throw e;
} Prevention
- Log the full 400 response body — the errors payload names the failing rule
- Keep server schema/migrations in sync (`ddev refresh`) to avoid rule mismatches
- Investigate custom Favorites table rules if this appears after upgrades
When it happens
Trigger: Favorites table delete() sets unexpected validation errors on the entity (e.g. database rule failures, integrity rules) other than user_id.is_owner, after a DELETE /favorites/{id} call.
Common situations: Database constraint/plugin customization altered favorite validation rules; data corruption where the favorite references a resource that no longer exists; version drift after an upgrade.
Related errors
- Could not save the account recovery setting.
- Could not validate comment data.
- Could not validate favorite data.
- Could not validate settings.
- Few fields are missing for the V5.
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/02a4a763d49db980.
Report an issue: GitHub.
Appendix: source
Thrown at src/Service/Favorites/FavoritesDeleteService.php:82
/**
* Manage delete errors.
*
* @param \App\Model\Entity\Favorite $favorite Favorite entity.
* @return void
* @throws \Cake\Http\Exception\NotFoundException When user cannot delete this favorite entity.
* @throws \Cake\Http\Exception\BadRequestException When unable to delete the entity.
*/
private function _handleDeleteErrors(Favorite $favorite): void
{
$errors = $favorite->getErrors();
if (!empty($errors)) {
if (isset($errors['user_id']['is_owner'])) {
throw new NotFoundException(__('The favorite does not exist.'));
}
throw new BadRequestException(__('Could not delete favorite.'));
}
}
}
View on GitHub (pinned to 31c1bbc10f)