Hello @jeffladiray
Alright so, first, I think I do have to apologize as I am always use to post detailled issue. This time I feel like you’re missing information, so I am really sorry about it
Actual Behavior
So, if we take forest admin routes responses, based on request(s), we (from my pov) have 4 different basic situation:
- Action: success (200?)
- Action: error (500?)
- SmartAction: success (200?)
- SmartAction: error (500?)
Even if there can be different relative codes, such as:
- 401 Unauthorized
- 201 Created
Let’s focus on 200 & 500 for now.
If we have only two scenarios possible, success or error, then here you can find the behavior for each scenarios:
- Success message within body (200) on Action
// Create a Product
router.post('/products', permissionMiddlewareCreator.create(), (request, response, next) => {
// Learn what this route does here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#create-a-record
let message = "hey";
console.log(message);
response.status(200).send({success: message});
return
});
- Success message (200) on Action
// Create a Product
router.post('/products', permissionMiddlewareCreator.create(), (request, response, next) => {
// Learn what this route does here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#create-a-record
let message = "hey";
console.log(message);
response.status(200).send(message);
return
});
- Success message within body (200) on Smart Action
// Release to prod
router.post('/actions/products/release-to-prod', permissionMiddlewareCreator.smartAction(), (request, response) => {
let message = "hey";
console.log(message);
response.status(200).send({success: message});
return
});
- Success message (200) on Smart Action
// Release to prod
router.post('/actions/products/release-to-prod', permissionMiddlewareCreator.smartAction(), (request, response) => {
let message = "hey";
console.log(message);
response.status(200).send(message);
return
});
So as of now, we can see that the message seems unmutable within action. However, for smart action, sending a message within the body works (using success field).
- Error message within body (500) on Action
// Create a Product
router.post('/products', permissionMiddlewareCreator.create(), (request, response, next) => {
// Learn what this route does here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#create-a-record
let message = "hey";
console.log(message);
response.status(500).send({error: message});
return
});
- Error message (500) on Action
// Create a Product
router.post('/products', permissionMiddlewareCreator.create(), (request, response, next) => {
// Learn what this route does here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#create-a-record
let message = "hey";
console.log(message);
response.status(500).send(message);
return
});
- Error message within body (500) on Smart Action
// Release to prod
router.post('/actions/products/release-to-prod', permissionMiddlewareCreator.smartAction(), (request, response) => {
let message = "hey";
console.log(message);
response.status(500).send({error: message});
return
});
- Error message (500) on Smart Action
// Release to prod
router.post('/actions/products/release-to-prod', permissionMiddlewareCreator.smartAction(), (request, response) => {
let message = "hey";
console.log(message);
response.status(500).send(message);
return
});
We can note from these error that if you send a clear string message on action error, it works but you get an extras Products creation failed:
in front of your message. On smart action it’s totally KO
We these 8 examples, we can see that the behavior isn’t the same all time between success & errors, but also between action & smart actions…
Expected Behavior
It doesn’t matter if I specify a body or just a string, based on the code type (2xx, 4xx, 5xx), the result/behavior should be the same between action & smart action.
Bonus
It could be amazing to choose he toaster color !
Thank you so much for your time, I hope it helps
Best,
Max