stackvana / hook.io

Open-Source Microservice Hosting Platform
https://hook.io
Other
1.27k stars 119 forks source link

API call /new with non-lowercase name creates inaccessible hooks #237

Open pyhedgehog opened 8 years ago

pyhedgehog commented 8 years ago

Page https://hook.io/pythonsdktest contains hook 80e2416a-a987-417c-bd65-7368eb43df31-5A9D9260-bug. Bug attempt to access any of following results in 404: https://hook.io/pythonsdktest/80e2416a-a987-417c-bd65-7368eb43df31-5A9D9260-bug https://hook.io/pythonsdktest/80e2416a-a987-417c-bd65-7368eb43df31-5A9D9260-bug/source https://hook.io/pythonsdktest/80e2416a-a987-417c-bd65-7368eb43df31-5A9D9260-bug/logs https://hook.io/pythonsdktest/80e2416a-a987-417c-bd65-7368eb43df31-5A9D9260-bug/resource

Marak commented 8 years ago

That's weird. Is problem with -? Or perhaps with length of service name?

pyhedgehog commented 8 years ago

This is true about all services in pythonsdktest except hooktest. It states that hook name can be 50 chars. So not any of these causes:

  1. Name length
  2. Underscore in name (_)
  3. Non-identified name (number in front)
Marak commented 8 years ago

50 is problem if validation not propagate to client request!

I find issue tonight where validation fail and fix.

URL max length is 2,083 characters, so I think maybe I can increase service name to 255?

Marak commented 8 years ago

Thank you for finding! Much appreciated.

pyhedgehog commented 8 years ago

I'm writing test for sdk. :smile:

Marak commented 8 years ago

SDK integration test I have, https://github.com/bigcompany/hook.io-test/tree/master/tests/client

pyhedgehog commented 8 years ago

Thank you for reference - I'll look and rewrite. Shouldn't they use hook.io-sdk?

Marak commented 8 years ago

I'm not sure. Is just as easy to have raw requests, easier to read and understand tests.

Do whatever is easiest for you. sdk should probably just have unit tests with mock responses.

I have no preference.

pyhedgehog commented 8 years ago

So this tests are not for SDK, but for server itself? Fine. What about reason of 404?

Marak commented 8 years ago

Is bug I find in validation. Somewhere it's cutting off, probably in database save. I fix tonight.

Marak commented 8 years ago

@pyhedgehog - I can't replicate issue locally or on production.

Did you create these services through website page or SDK?

Can you reproduce again with new hook?

pyhedgehog commented 8 years ago

New hook is https://hook.io/pythonsdktest/testeb43df31_7E52B21Ehook Same behaviour - can't run, log or remove.

Marak commented 8 years ago

Is same question, how did you make hook? From SDK or web UI?

Marak commented 8 years ago

Is problem only with long names? Is problem with random hook creation?

Is problem with creating from SDK client?

pyhedgehog commented 8 years ago

Problem with hooks created from python SDK client.

pyhedgehog commented 8 years ago

Will it help if I craft curl call to reproduce problem?

Marak commented 8 years ago

Yes

pyhedgehog commented 8 years ago

I've found when it's happens: when hook name contains upper-case letters.

This is curl command line for demonstration: curl -i -vvv -H "hookio-private-key: $hook_private_key" -H 'accept: application/json' -H 'content-type: application/json' --data-raw '{"source":"print(globals())","name":"testABCDEFGH_bug237test08","language":"python"}' https://hook.io/new

Form (when you going to https://hook.io/new in browser) forces name to be lowercase, but server-side script should check it too. Also we have several hooks left in incorrect state (I can't ever delete them).

pyhedgehog commented 8 years ago

At least please remove all invalid hooks from https://hook.io/pythonsdktest - i.e. please remove all except pythonsdktest/hooktest.

Marak commented 8 years ago

Will make sure to review /new for next deployment.

I will clear out your test account as well.

Thank you.