'CustomKeyCheck' object has no attribute 'arg_count'

Hi all!
I’m trying to write a python plugin that replaces the key verification done by Tyk with a custom one (essentially pass the token below the chain if there is one).

Following this example, I wrote it, but I always get

“Hook ‘MyAuthMiddleware’ returned an error: ‘CustomKeyCheck’ object has no attribute ‘arg_count’”

when an API is called.
The manifest.json is simply:

{
  "file_list": [
"middleware.py"
  ],
  "custom_middleware": {
"auth_check": {
  "name": "MyAuthMiddleware"
},
"driver": "python"
  }
}

If, instead, I use the @Hook decorator then I don’t have this issue, but the key verification fails.
Finally, I’ve this issue also with the @Pre decorator.

Hi, this is an old sample. It should follow this convention.

Could you share your middleware code to see why the verification fails?

Hi,
in the end seemed like the metadata['token'] was mandatory: https://github.com/TykTechnologies/tyk/issues/2416
What is ugly is that a new API key is generated from such token passed in the metadata, so if I use as token something like “some-random-string” (just to make the validation pass), then I can actually use “some-random-string” as API key.

Is it like that by design? To me, this seems more a bug…