dolibarr icon indicating copy to clipboard operation
dolibarr copied to clipboard

REST post to /supplierinvoices/{id}/lines does not say what fields are missing and returns a cryptic database error

Open dpriskorn opened this issue 3 years ago • 3 comments

Bug

this endpoint does not have required fields set it seems

Environment

  • Version: 12

Expected and actual behavior

dolibarr should not pass on data to the database without ensuring all the necessary fields are present.

Steps to reproduce the behavior

send this: {"socid": "768", "qty": "1", "fk_product": "1437"} returns: { "error": { "code": 400, "message": "Bad Request: Unable to insert the new line. Check your inputs. ERROR: 42601: syntax error at or near ","\nLINE 1: ...ll, null, '', '', 1, '', 0, 0, 0, '0', '0', 1437, , 0, 0, 0,...\n ^\nLOCATION: scanner_yyerror, scan.l:1145" }, "debug": { "source": "api_supplier_invoices.class.php:565 at call stage", "stages": {

dpriskorn avatar Aug 02 '20 21:08 dpriskorn

Looking closer in the log I found this: 2020-08-02 21:34:55 DEBUG 127.0.0.1 sql=INSERT INTO llx_facture_fourn_det (fk_facture_fourn, fk_parent_line, label, description, ref, qty, vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, fk_product, product_type, remise_percent, pu_ht, pu_ttc, date_start, date_end, fk_code_ventilation, rang, special_code, info_bits, total_ht, tva, total_ttc, total_localtax1, total_localtax2, fk_unit, fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc) VALUES (109, null, null, '', '', 1, '', 0, 0, 0, '0', '0', 1437, , 0, 3, 3, null, null, 0, 0, 0, '0', 3, 0, 3, 0, 0, NULL, 0, 'SEK', 3, 3, 0, 3) 2020-08-02 21:34:55 ERR 127.0.0.1 DoliDBPgsql::query SQL Error message: ERROR: 42601: syntax error at or near "," LINE 1: ...ll, null, '', '', 1, '', 0, 0, 0, '0', '0', 1437, , 0, 3, 3,... ^ LOCATION: scanner_yyerror, scan.l:1145 (DB_ERROR_SYNTAX)

product_type is mandatory and should be checked. This returns 200: {"socid": "768", "qty": "1", "fk_product": "1437", "tva_tx": "25.00000000", "pu_ht": "3.00000000", "product_type": "0" }

dpriskorn avatar Aug 02 '20 21:08 dpriskorn

can someone check this on v14?

dpriskorn avatar Aug 05 '21 12:08 dpriskorn

This issue is stale because it has been open 1 year with no activity. If this is a bug, please comment to confirm it is still present on latest stable version. if this is a feature request, please comment to notify the request is still relevant and not yet covered by latest stable version. This issue may be closed automatically by stale bot in 10 days (you should still be able to re-open it if required).

github-actions[bot] avatar Aug 05 '22 21:08 github-actions[bot]