ShlomoCode / yemot-router2

https://www.npmjs.com/yemot-router2
MIT License
10 stars 3 forks source link

שגיאה בהגדרה removeInvalidChars: true ברמת הראוטר #43

Open abaye123 opened 1 month ago

abaye123 commented 1 month ago

שגיאה בהגדרה removeInvalidChars: true ברמת הראוטר

כשאני מגדיר removeInvalidChars: true ברמת הנתב תחת ברירות המחדל, כך:

import { YemotRouter } from 'yemot-router2';
import express from 'express';

export const app = express();

export const router = YemotRouter({
    printLog: true,
    timeout: 300000,
    uncaughtErrorHandler: (error, call) => {
        console.log(`Uncaught error in ${call.req.path} from ${call.phone}. error stack: ${error.stack}`);
        return call.id_list_message([{ type: 'text', data: 'התרחשה שגיאה. פנה למנהל המערכת' }]);
    },
    defaults: {
        removeInvalidChars: true
    }
});

router.all('*', function (call) {
    console.log(`General request to an unspecified address. url: ${call.req.path} from ${call.phone} to ${call.ApiDID}`);
    call.id_list_message([{ type: 'text', data: '.כתובת לא מוכרת בשרת' }]);
});

export default router;

מתקבלת השגיאה הבאה:

[0637ded3ada490d8854e3b03c674b4ff924a948c]: 📞 new call - from 0555555555 General request to an unspecified address. url: / from 0555555555 to 0777777777 [0637ded3ada490d8854e3b03c674b4ff924a948c]: 💥 Uncaught error. applying uncaughtErrorHandler (file:///var/www/production/node_modules/yemot-router2/lib/response_functions.js:118:15) Uncaught error in / from 0555555555. error stack: CallError: message '.כתובת לא מוכרת בשרת' has invalid characters for yemot: . at validateCharsForTTS (file:///var/www/el/node_modules/yemot-router2/lib/response_functions.js:118:15) at makeMessagesData (file:///var/www/el/node_modules/yemot-router2/lib/response_functions.js:137:13) at Call.id_list_message (file:///var/www/el/node_modules/yemot-router2/lib/call.js:239:34) at file:///var/www/el/ph/router_calls.js:21:10 at makeNewCall (file:///var/www/el/node_modules/yemot-router2/lib/yemot_router.js:73:19) at file:///var/www/el/node_modules/yemot-router2/lib/yemot_router.js:152:29 at Layer.handle [as handle_request] (/var/www/el/node_modules/express/lib/router/layer.js:95:5) at next (/var/www/el/node_modules/express/lib/router/route.js:149:13) at Route.dispatch (/var/www/el/node_modules/express/lib/router/route.js:119:3) at Layer.handle [as handle_request] (/var/www/el/node_modules/express/lib/router/layer.js:95:5) 💥 Error in uncaughtErrorHandler! process is crashing node:internal/process/promises:279 triggerUncaughtException(err, true /* fromPromise */);

ShlomoCode commented 1 month ago

תודה על הדיווח. פתרון זמני:

defaults: {
    id_list_message: {
        removeInvalidChars: true
    },
    read: {
        removeInvalidChars: true
    }
}
abaye123 commented 1 month ago

אכן זה עובד,

ashuvax commented 1 month ago

יותר נכון ככה:

    defaults: {
        id_list_message: {
            removeInvalidChars: true
        },
        read: {
            record: {
                removeInvalidChars: true
            },
            stt: {
                removeInvalidChars: true
            },
            tap: {
                removeInvalidChars: true
            }
        }
    }
ShlomoCode commented 1 month ago

@ashuvax באיזה מקרה ההגדרה הקודמת לא עובדת לך? זה לא אמור להשפיע יותר ככה

ashuvax commented 1 month ago

אה אוקיי מצוין!