hook.io icon indicating copy to clipboard operation
hook.io copied to clipboard

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

Open pyhedgehog opened this issue 9 years ago • 20 comments

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

pyhedgehog avatar May 18 '16 20:05 pyhedgehog

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

Marak avatar May 18 '16 20:05 Marak

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)

pyhedgehog avatar May 18 '16 20:05 pyhedgehog

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 avatar May 18 '16 20:05 Marak

Thank you for finding! Much appreciated.

Marak avatar May 18 '16 20:05 Marak

I'm writing test for sdk. :smile:

pyhedgehog avatar May 18 '16 21:05 pyhedgehog

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

Marak avatar May 18 '16 21:05 Marak

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

pyhedgehog avatar May 18 '16 21:05 pyhedgehog

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.

Marak avatar May 18 '16 21:05 Marak

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

pyhedgehog avatar May 18 '16 21:05 pyhedgehog

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

Marak avatar May 18 '16 21:05 Marak

@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?

Marak avatar May 19 '16 02:05 Marak

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

pyhedgehog avatar May 19 '16 08:05 pyhedgehog

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

Marak avatar May 19 '16 09:05 Marak

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

Is problem with creating from SDK client?

Marak avatar May 19 '16 09:05 Marak

Problem with hooks created from python SDK client.

pyhedgehog avatar May 19 '16 10:05 pyhedgehog

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

pyhedgehog avatar May 20 '16 11:05 pyhedgehog

Yes

Marak avatar May 20 '16 12:05 Marak

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 avatar May 20 '16 15:05 pyhedgehog

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

pyhedgehog avatar Sep 26 '16 17:09 pyhedgehog

Will make sure to review /new for next deployment.

I will clear out your test account as well.

Thank you.

Marak avatar Sep 26 '16 17:09 Marak