Nvds_rest_server: handleRemoveStream always return NvDsServerStatusCode::StatusOk

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU): GPU
• DeepStream Version: 7.0
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs): bug
**• How to reproduce the issue ?
call ‘http://localhost:9000/api/v1/stream/remove’ api returns 200 though request is invalid.
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)

Are you testing deepstream-server or nvmultiurisrcbin ?

For nvmultiurisrcbin, apply this patch, then make CUDA_VER=12.6 install (for DS-7.1, DS-7.0 is similar)

diff --git a/sources/gst-plugins/gst-nvmultiurisrcbin/gstdsnvmultiurisrcbin.cpp b/sources/gst-plugins/gst-nvmultiurisrcbin/gstdsnvmultiurisrcbin.cpp
index a5e6d42..556054f 100644
--- a/sources/gst-plugins/gst-nvmultiurisrcbin/gstdsnvmultiurisrcbin.cpp
+++ b/sources/gst-plugins/gst-nvmultiurisrcbin/gstdsnvmultiurisrcbin.cpp
@@ -1639,6 +1639,9 @@ s_stream_api_impl (NvDsServerStreamInfo * stream_info, void *ctx)
               (GstElementCallAsyncFunc) gst_bin_sync_children_states, NULL, NULL);
         }
       } else {
+        stream_info->status = STREAM_REMOVE_FAIL;
+        stream_info->stream_log = "STREAM_REMOVE_FAIL,Not Find source stream";
+        stream_info->err_info.code = StatusInternalServerError;
         GST_WARNING_OBJECT (nvmultiurisrcbin,
             "No record found; Failed to remove sensor id=[%s] uri=[%s]\n",
             stream_info->value_camera_id.c_str (),

For deepstream-server, Modify the s_stream_callback_impl function in deepstream-server/rest_server_callbacks.cpp according to this patch

I am testing nvmultiurisrcbin. we are trying to test remove camera feature.
nvds_rest_stream_parse returns false due to bad request, due to this stream_cb is not called.
still handleRemoveStream return StatusOk, which is 200. Actually it should return 400.

In the above patch, change it to stream_info->err_info.code = StatusBadRequest

In fact, the HTTP DELETE method should be used here instead of POST. This may be improved later.

The current implementation of nvds_rest_stream_parse marks the request as a Bad Request and returns false if the camera URL or camera ID is empty. However, handleRemoveStream still returns StatusOk (HTTP 200) in such cases. In my opinion, handleRemoveStream should instead return StatusBadRequest to accurately reflect the invalid input scenario.

This behavior is correct, but this code is ok

gst-launch-1.0 nvmultiurisrcbin port=9000 ip-address=localhost batched-push-timeout=33333 max-batch-size=10 drop-pipeline-eos=1 live-source=1 width=2560 height=1440 uri-list=file:///opt/nvidia/deepstream/deepstream/samples/streams/sample_1080p_h264.mp4  ! nvmultistreamtiler ! nv3dsink

Empty camera url request

curl -XPOST 'http://localhost:9000/api/v1/stream/remove' -d '{
    "key": "sensor",
    "value": {
        "camera_id": "uniqueSensorID1",
        "camera_name": "",
        "camera_url": "",
        "change": "camera_remove",
        "metadata": {
            "resolution": "1920 x1080",
            "codec": "h264",
            "framerate": 30
        }
    },
    "headers": {
        "source": "vst",
        "created_at": "2021-06-01T14:34:13.417Z"
    }
}'

Result

{
	"reason" : "STREAM_REMOVE_FAIL, Source url empty",
	"status" : "HTTP/1.1 400 Bad Request"
}