microsoft / BotFramework-WebChat

A highly-customizable web-based client for Azure Bot Services.
https://www.botframework.com/
MIT License
1.6k stars 1.54k forks source link

Wildcard route problem in sample `k.direct-line-token/javascript/web` #4872

Open ramfattah opened 1 year ago

ramfattah commented 1 year ago

Is it an issue related to Adaptive Cards?

No

Is this an accessibility issue?

No

What version of Web Chat are you using?

Latest production

Which distribution are you using Web Chat from?

Unrelated

Which hosting environment does this issue primarily affect?

Web apps

Which browsers and platforms do the issue happened?

Browser: Edge (latest)

Which area does this issue affect?

Protocol or service

What is the public URL for the website?

No response

Please describe the bug

The wildcard route (/*/) defined in index.js is causing an error due to improper formatting for Restify.

Do you see any errors in console log?

Error: Wildcard must be the last character in the route
    at Router._on (/Users/ram/Documents/bot/BotFramework-WebChat/samples/01.getting-started/k.direct-line-token/javascript/web/node_modules/find-my-way/index.js:266:15)
    at Router.on (/Users/ram/Documents/bot/BotFramework-WebChat/samples/01.getting-started/k.direct-line-token/javascript/web/node_modules/find-my-way/index.js:135:10)
    at RouterRegistryRadix.add (/Users/ram/Documents/bot/BotFramework-WebChat/samples/01.getting-started/k.direct-line-token/javascript/web/node_modules/restify/lib/routerRegistryRadix.js:42
:21)
    at Router.mount (/Users/ram/Documents/bot/BotFramework-WebChat/samples/01.getting-started/k.direct-line-token/javascript/web/node_modules/restify/lib/router.js:214:20)
    at Server.serverMethod [as get] (/Users/ram/Documents/bot/BotFramework-WebChat/samples/01.getting-started/k.direct-line-token/javascript/web/node_modules/restify/lib/server.js:1779:33)
    at Object.<anonymous> (/Users/ram/Documents/bot/BotFramework-WebChat/samples/01.getting-started/k.direct-line-token/javascript/web/src/index.js:31:10)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at Object.nodeDevHook [as .js] (/Users/ram/Documents/bot/BotFramework-WebChat/samples/01.getting-started/k.direct-line-token/javascript/web/node_modules/node-dev/lib/hook.js:54:7)
    at Module.load (node:internal/modules/cjs/loader:1076:32)
(node:68371) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
[ERROR] 00:06:17 Error: Wildcard must be the last character in the route

How to reproduce the issue?

  1. Navigate to k.direct-line-token/javascript/web root project directory.
  2. Resolve #4871 locally by adding asyn/await in post request handler
  3. Run npm start to start the server.
  4. The server fails to start, citing an issue with the wildcard route.

What do you expect?

The server should start without any errors and handle requests to all routes.

What actually happened?

Server startup failed due to the wildcard route issue in index.js.

Do you have any screenshots or recordings to repro the issue?

No response

Adaptive Card JSON

No response

Additional context

Restify (or its underlying router) expects any wildcard * to be the last character in the route path.

ramfattah commented 1 year ago

🔗 Related Issues: https://github.com/microsoft/BotFramework-WebChat/issues/4871, https://github.com/microsoft/BotFramework-WebChat/issues/4872, https://github.com/microsoft/BotFramework-WebChat/issues/4873

I've identified these issues are all related to the k.direct-line-token sample. I'm currently working on a fix to address all three issues together.