Python middleware error when trying example from documentation

Hi Yegor,

I’m not able to recreate the problem, even when using the bundle you attached
A couple of things though.

You don’t need "driver": "python", specified in the API defn when you are using a bundle. That info comes from the manifest.

Perhaps most importantly, when you change or rebuild the bundle you have to either change its name and update the API defn or remove the directory containing it from under /opt/tyk-gateway/middleware/bundles and restart the gateway.

Here are the logs from loading and running your bundle.You can see the error returned from python about 100 being an int.

time="Jun 29 12:31:41" level=info msg="----> Loading bundle: tyk-plugins_bundle" prefix=main
time="Jun 29 12:31:41" level=info msg="----> Verifying bundle: tyk-plugins_bundle" prefix=main
time="Jun 29 12:31:41" level=info msg="----> Bundle verification failed: tyk-plugins_bundle" prefix=main
time="Jun 29 12:31:41" level=info msg="----> Bundle is valid, adding to spec: tyk-plugins_bundle" prefix=main
time="Jun 29 12:31:41" level=info msg="Loading module: '03887748b566415d6e7ab28335400e2e_1e824b2eed8a5ee24cd7cdf54ba30c5e'" prefix=python
time="Jun 29 12:31:41" level=info msg="Checking security policy: Open" api_id=03887748b566415d6e7ab28335400e2e api_name=pytest2 org_id=60db07e75ec6770023473eaf
time="Jun 29 12:31:41" level=info msg="Initialised API Definitions" prefix=main
time="Jun 29 12:31:41" level=info msg="API reload complete" prefix=main
time="Jun 29 12:32:00" level=info msg="ResponseHook request_body contained " prefix=python
time="Jun 29 12:32:00" level=error msg="PyObjectCallObject failed" prefix=python
time="Jun 29 12:32:00" level=error msg="Hook 'ResponseHook' returned an error: 100 has type int, but expected one of: bytes, unicode" prefix=python

And here’s the section from the API

"custom_middleware": {
  "pre": [],
  "post": [],
  "post_key_auth": [],
  "auth_check": {
    "name": "",
    "path": "",
    "require_session": false,
    "raw_body_only": false
  },
  "response": [],
  "driver": "",
  "id_extractor": {
    "extract_from": "",
    "extract_with": "",
    "extractor_config": {}
  }
},
"custom_middleware_bundle": "tyk-plugins_bundle",

Cheers,
Pete