dOpensource / dsiprouter

UI Interface for implementing Kamailio to provide PBX Hosting and SIP Trunking Services
https://dsiprouter.org
Apache License 2.0
194 stars 103 forks source link

[BUG] 500 Server Error from Comma in Inbound Route Name Field #547

Open bowyern opened 9 months ago

bowyern commented 9 months ago

Describe the bug If you add a comma to the Friendly Name field of an Inbound route, either via Add or Import, Inbound Routes will return a 500 server error after that.

Manually removing the comma from the description name: field in the database restores UI functionality.

To Reproduce Go to Inbound Routes. Click Add. Put "Test 1, 2, 3" in the Friendly Name field. Put any 10 digits into the DID field. Select an Endpoint group. Click Add. See 500 server error.

Expected behavior The number should be added, or it should error on incorrect user input.

Server Info:

bowyern commented 9 months ago

I think this is related:

[2023-12-27 15:47:19] [1023223->139957682251584] [ERROR]: ((( EXCEPTION ))) [CLASS]: <class 'ValueError'> [VALUE]: dictionary update sequence element #1 has length 1; 2 is required ((( BACKTRACE )))

[SOURCE]: return render_template('inboundmapping.html', rows=res, gwgroups=gwgroups, epgroups=epgroups, imported_dids=dids)

devopsec commented 9 months ago

This issue is due to the description field in the DB being used as a comma separated list of sub-fields.
The fix would be to change the DB structure to JSON type or creating a related table for the data.
I would prefer just using the JSON type here as its simpler and is supported in the htables now: https://www.kamailio.org/docs/modules/devel/modules/htable.html#htable.p.htable