Projekt

Allgemein

Profil

Aktionen

GX-Bug #68835

offen

API v2 does not return a clean 200 OK for every missing entry or deletion of entries.

Von Till Tepelmann vor fast 3 Jahren hinzugefügt. Vor mehr als 2 Jahren aktualisiert.

Status:
Gemeldet
Priorität:
Normal
Zugewiesen an:
-
Kategorie:
REST-API
Zielversion:
-
% erledigt:

0%

Geschätzter Aufwand:
Steps to reproduce:
Betroffene Versionen:
4.4.0.1, 4.4.0.2
Release Notes Langtext:

Beschreibung

Wir sollten prüfen in wie fern ein 404 oder ein 200 OK ohne Backtrace in der API Response passieren sollte.

Der Endpunkt DELETE /v2/products/22 liefert immer eine Exception "product with the ID 22 not found" mit einem 200 OK und einem Backtrace

Erwartetes Verhalten:
Der Response sollte ein 200 OK liefern wenn er ohne Fehler ausgeführt wurde.
Wenn aber ein Fehler auftritt, z.B. Artikel wurde nicht gefunden, sollte kein Backtrace angezeigt werden, sondern nur die Meldung "product with the ID 22 not found" mit einer "failed" status und evetuell ein 404 oder 200, das müssten dann noch mal besprochen werden.


{
"code": 200,
"status": "failed",
"action": "delete",
"resource": "Product",
"productId": 22,
"errorMessage": "product with the ID 22 not found"
}

Tatsächliches Verhalten:
Wenn man ein Artikel löschen will, der nicht existiert, wird ein 200 OK mit einer Exception angezeigt und einem Backtrace.


We should check how far a 404 or a 200 OK should happen without a backtrace in the API response.

The endpoint DELETE /v2/products/22 always returns an exception "product with the ID 22 not found" with a 200 OK and a backtrace.

Expected behavior:
The response should return a 200 OK if it was executed without error.
But if an error occurs, e.g. article was not found, no backtrace should be displayed, but only the message "product with the ID 22 not found" with a "failed" status and possibly a 404 or 200, this would have to be discussed again.


{
"code": 200,
"status": "failed",
"action": "delete",
}, "resource": "product",
"productId": 22,
"errorMessage": "product with the ID 22 not found"
}

Actual behavior:
When trying to delete an item that does not exist, a 200 OK is displayed with an exception and a backtrace.


Error-Meldung #2:
{
"errorMessage": "The requested product was not found in database (ID:
22)",
"stacktrace": [
{
"file":
"/var/www/GXMainComponents/Services/Core/Product/Repositories/ProductReposit
ory.inc.php",
"line": 153,
"function": "getById",
"class": "ProductRepositoryReader",
"type": "->",
"args": [
{}
]
},
{
"file":
"/var/www/GXMainComponents/Services/Core/Product/ProductWriteService.inc.php
",
"line": 160,
"function": "getProductById",
"class": "ProductRepository",
"type": "->",
"args": [
{}
]
},
{
"file":
"/var/www/GXMainComponents/Controllers/Api/v2/ProductsApiV2Controller.inc.ph
p",
"line": 699,
"function": "deleteProductById",
"class": "ProductWriteService",
"type": "->",
"args": [
{}
]
},
{
"file":
"/var/www/GXMainComponents/Controllers/Api/v2/ProductsApiV2Controller.inc.ph
p",
"line": 647,
"function": "_deleteProduct",
"class": "ProductsApiV2Controller",
"type": "->",
"args": [
{}
]
},
{
"file":
"/var/www/GXMainComponents/Controllers/Api/v2/ProductsApiV2Controller.inc.ph
p",
"line": 191,
"function": "_processSingleDelete",
"class": "ProductsApiV2Controller",
"type": "->",
"args": [
{}
]
},
{
"file": "/var/www/api.php",
"line": 144,
"function": "delete",
"class": "ProductsApiV2Controller",
"type": "->",
"args": []
},
{
"file":
"/var/www/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php",
"line": 43,
"function": "{closure}",
"args": [
{},
{},
{
"uri": "products/22"
}
]
},
{
"file": "/var/www/vendor/slim/slim/Slim/Routing/Route.php",
"line": 381,
"function": "__invoke",
"class": "Slim\\Handlers\\Strategies\\RequestResponse",
"type": "->",
"args": [
{},
{},
{},
{
"uri": "products/22"
}
]
},
{
"file":
"/var/www/vendor/slim/slim/Slim/MiddlewareDispatcher.php",
"line": 81,
"function": "handle",
"class": "Slim\\Routing\\Route",
"type": "->",
"args": [
{}
]
},
{
"file":
"/var/www/vendor/slim/slim/Slim/MiddlewareDispatcher.php",
"line": 81,
"function": "handle",
"class": "Slim\\MiddlewareDispatcher",
"type": "->",
"args": [
{}
]
},
{
"file": "/var/www/vendor/slim/slim/Slim/Routing/Route.php",
"line": 341,
"function": "handle",
"class": "Slim\\MiddlewareDispatcher",
"type": "->",
"args": [
{}
]
},
{
"file":
"/var/www/vendor/slim/slim/Slim/Routing/RouteRunner.php",
"line": 84,
"function": "run",
"class": "Slim\\Routing\\Route",
"type": "->",
"args": [
{}
]
},
{
"file":
"/var/www/vendor/slim/slim/Slim/Middleware/ErrorMiddleware.php",
"line": 107,
"function": "handle",
"class": "Slim\\Routing\\RouteRunner",
"type": "->",
"args": [
{}
]
},
{
"file":
"/var/www/vendor/slim/slim/Slim/MiddlewareDispatcher.php",
"line": 140,
"function": "process",
"class": "Slim\\Middleware\\ErrorMiddleware",
"type": "->",
"args": [
{},
{}
]
},
{
"file":
"/var/www/vendor/slim/slim/Slim/MiddlewareDispatcher.php",
"line": 81,
"function": "handle",
"class":
class /var/www/vendor/slim/slim/Slim/MiddlewareDispatcher.php,
"type": "->",
"args": [
{}
]
},
{
"file": "/var/www/vendor/slim/slim/Slim/App.php",
"line": 215,
"function": "handle",
"class": "Slim\\MiddlewareDispatcher",
"type": "->",
"args": [
{}
]
},
{
"file": "/var/www/vendor/slim/slim/Slim/App.php",
"line": 199,
"function": "handle",
"class": "Slim\\App",
"type": "->",
"args": [
{}
]
},
{
"file": "/var/www/api.php",
"line": 266,
"function": "run",
"class": "Slim\\App",
"type": "->",
"args": []
}
]
}


Aktionen #1

Von Till Tepelmann vor fast 3 Jahren aktualisiert

Aktionen #2

Von Moritz Bunjes vor mehr als 2 Jahren aktualisiert

  • Zielversion 133 wurde gelöscht
Aktionen

Auch abrufbar als: Atom PDF