When a request is sent to the /api/tables/invoices/rows?_extend=CustomerId API endpoint, Soul returns data from both the invoices and customer tables by extending the request using the CustomerId field. However, if an invalid foreign key is used in the _extend parameter, such ascustomerIdorTotal, Soul returns an error message stating"Foreign key not found."` Currently, if an invalid key is passed, Soul crashes and needs to be manually restarted.
Reason for the error
The reason for the error is that the listTableRows function in the core/src/controllers/rows.js file sends the res.send(400) signal to the client multiple times.
Modification
I have modified the error handling so that HTTP responses can't be sent to the client multiple times.
Purpose of the PR
/api/tables/invoices/rows?_extend=CustomerId
API endpoint, Soul returns data from both the invoices and customer tables by extending the request using theCustomerId
field. However, if an invalid foreign key is used in the_extend parameter, such as
customerIdor
Total, Soul returns an error message stating
"Foreign key not found."` Currently, if an invalid key is passed, Soul crashes and needs to be manually restarted.Reason for the error
listTableRows
function in thecore/src/controllers/rows.js
file sends theres.send(400)
signal to the client multiple times.Modification