irods / irods_client_http_api

An iRODS C++ HTTP API using Boost.Beast
BSD 3-Clause "New" or "Revised" License
0 stars 8 forks source link

Improve logging when invalid requests are sent #353

Open MartinFlores751 opened 5 hours ago

MartinFlores751 commented 5 hours ago

If I curl:

curl -H"Authenticate: a.b.c" http://172.18.0.3:9000/irods-http-api/0.4.0/collections -v
*   Trying 172.18.0.3:9000...
* Connected to 172.18.0.3 (172.18.0.3) port 9000
* using HTTP/1.x
> GET /irods-http-api/0.4.0/collections HTTP/1.1
> Host: 172.18.0.3:9000
> User-Agent: curl/8.10.1
> Accept: */*
> Authenticate: a.b.c
>  
* Request completely sent off
< HTTP/1.1 500 Internal Server Error
< Server: irods_http_api/0.4.0 (76555f99cfad6a99b7d6a9b1099806840ee87022)
< Content-Type: application/json
< Content-Length: 0
<  
* Connection #0 to host 172.18.0.3 left intact

Error logs produced should be concise, instead of the following when able:

[2024-11-05 17:53:02.902] [P:13770] [debug] [T:13791] [172.18.0.1] on_read: Needs EOF: false
[2024-11-05 17:53:02.902] [P:13770] [error] [T:13791] parse_url: curl_url_get(CURLUPART_QUERY) error: 16
[2024-11-05 17:53:03.143] [P:13770] [error] [T:13791] [172.18.0.1] on_read: iRODS Exception:
    file: /http_api_source/core/src/common.cpp
    function: irods::http::url irods::http::parse_url(const std::string &)
    line: 213
    code: -167000 (SYS_LIBRARY_ERROR)
    message:
        curl_url_get(CURLUPART_QUERY) error.
stack trace:
--------------
 0# irods::stacktrace::dump() const in /lib/libirods_common.so.4.3.2
 1# irods::exception::assemble_full_display_what() const in /lib/libirods_common.so.4.3.2
 2# irods::exception::what() const in /lib/libirods_common.so.4.3.2
 3# irods::http::session::on_read(boost::system::error_code, unsigned long) in irods_http_api
...
21# boost_asio_detail_posix_thread_function in irods_http_api
22# 0x0000746C7D894AC3 in /lib/x86_64-linux-gnu/libc.so.6
23# clone in /lib/x86_64-linux-gnu/libc.so.6
MartinFlores751 commented 4 hours ago

The HTTP API does not crash in the example shown.