Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return error 400 if path part is invalid instead of 500 #56

Open
gugu opened this issue Apr 3, 2019 · 0 comments · May be fixed by #57
Open

Return error 400 if path part is invalid instead of 500 #56

gugu opened this issue Apr 3, 2019 · 0 comments · May be fixed by #57

Comments

@gugu
Copy link

gugu commented Apr 3, 2019

Current behaviour:
curl corp.short.cm/%AF returns 500 Internal Server Error
Expected:
curl corp.short.cm/%AF returns 400 Invalid request

I'm running a link shortener service and user put different combinations in path part, some of them are valid, some of them - not. This case I sent is a client error and there is no need to raise an exception here

URIError: URI malformed
  ?, in decodeURIComponent
  File "/srv/shorturl_redirector/node_modules/koa-route/index.js", line 60, col 19, in decode
    if (val) return decodeURIComponent(val);
  ?, in Array.map
  File "/srv/shorturl_redirector/node_modules/koa-route/index.js", line 34, col 35, in null.<anonymous>
    const args = m.slice(1).map(decode);
  File "/srv/shorturl_redirector/node_modules/koa-compose/index.js", line 42, col 32, in dispatch
    return Promise.resolve(fn(context, dispatch.bind(null, i + 1)));
  File "/srv/shorturl_redirector/node_modules/koa-route/index.js", line 43, col 16, in null.<anonymous>
    return next();
  File "/srv/shorturl_redirector/node_modules/koa-compose/index.js", line 42, col 32, in dispatch
    return Promise.resolve(fn(context, dispatch.bind(null, i + 1)));
  File "/srv/shorturl_redirector/node_modules/koa-route/index.js", line 43, col 16, in null.<anonymous>
    return next();
  File "/srv/shorturl_redirector/node_modules/koa-compose/index.js", line 42, col 32, in dispatch
    return Promise.resolve(fn(context, dispatch.bind(null, i + 1)));
  File "/srv/shorturl_redirector/node_modules/koa-route/index.js", line 43, col 16, in null.<anonymous>
    return next();
  File "/srv/shorturl_redirector/node_modules/koa-compose/index.js", line 42, col 32, in dispatch
    return Promise.resolve(fn(context, dispatch.bind(null, i + 1)));
  File "/srv/shorturl_redirector/node_modules/koa-route/index.js", line 43, col 16, in null.<anonymous>
    return next();
  File "/srv/shorturl_redirector/node_modules/koa-compose/index.js", line 42, col 32, in dispatch
    return Promise.resolve(fn(context, dispatch.bind(null, i + 1)));
  File "/srv/shorturl_redirector/node_modules/koa-route/index.js", line 43, col 16, in null.<anonymous>
    return next();
  File "/srv/shorturl_redirector/node_modules/koa-compose/index.js", line 42, col 32, in dispatch
    return Promise.resolve(fn(context, dispatch.bind(null, i + 1)));
  File "/srv/shorturl_redirector/node_modules/koa-views/src/index.js", line 55, col 12, in views
    return next()
  File "/srv/shorturl_redirector/node_modules/koa-compose/index.js", line 42, col 32, in dispatch
    return Promise.resolve(fn(context, dispatch.bind(null, i + 1)));
  File "/srv/shorturl_redirector/node_modules/koa-body/index.js", line 110, col 14, in null.<anonymous>
    return next();
  File "internal/process/next_tick.js", line 68, col 7, in process._tickCallback
@gugu gugu linked a pull request Apr 4, 2019 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant