fonoster / routr

⚡ The future of programmable SIP servers.
https://routr.io
MIT License
1.42k stars 147 forks source link

[BUG]: Incorrect response when X-Dod-Number is missing for peer-to-pstn routing #276

Open psanders opened 4 months ago

psanders commented 4 months ago

What happened?

When making peer-to-pstn routing, the X-Dod-Number number must be present, and the resource must exist. The system should respond with a "404 Not Found" if the number doesn't exist. And, if the X-Dod-Number is not present, then a "400 Bad Request."

Instead, the server responds with a "500 Internal Server Error."

"addr":"localhost:51903","postProcessor":true,"runPostProcessorMiddlewares":false}
2024-06-02 16:17:12.307 [verbose]: (dispatcher) /node_modules/@routr/dispatcher/dist/run_processor.js forwarding request to processor {"ref":"connect-processor"}
2024-06-02 16:17:12.308 [verbose]: (connect) /node_modules/@routr/connect/dist/service.js connect processor received new request {"ref":"ZciyO4tPU-ijq2G1xF.cmloIKmeX2-8L","method":"INVITE","type":"(request)","edgePort":"8c9965764120"}
2024-06-02 16:17:12.368 [verbose]: (connect) /node_modules/@routr/connect/dist/router.js routing request from: sip:voice@anonymous.invalid, to: sip:+17853178071@sip.local {"fromURI":"sip:voice@anonymous.invalid","requestURI":"sip:+17853178071@sip.local","routingDirection":"peer-to-pstn"}
2024-06-02 16:17:12.370 [error]: (connect) /node_modules/@routr/connect/dist/handlers/request.js no Number found for tel: null {}
2024-06-02 16:17:12.371 [verbose]: (dispatcher) /node_modules/@routr/dispatcher/dist/run_middlewares.js sending request to middleware {"ref":"ZciyO4tPU-ijq2G1xF.cmloIKmeX2-8L","middlewareRef":"rtprelay-middleware","addr":"localhost:51903","postProcessor":true,"runPostProcessorMiddlewares":true}
2024-06-02 16:17:12.372 [verbose]: (dispatcher) /node_modules/@routr/dispatcher/dist/run_middlewares.js found messageType to be responseType and broke the chain {"ref":"ZciyO4tPU-ijq2G1xF.cmloIKmeX2-8L","middlewareRef":"rtprelay-middleware","addr":"localhost:51903"}

Example of request.

Screenshot 2024-06-18 at 12 18 19 PM

Relevant code.

Screenshot 2024-06-18 at 12 22 53 PM

Steps to reproduce

Attempt to make a peer-to-pstn without the X-Dod-Number header or with an X-Dod-Number without the corresponding resource. Observe the signaling return a 500 error from Routr.returns

Expected behavior

We must validate the input and return the corresponding error if the resource is not found.

Additional context

No response