-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Branch/Environment/Version
- Branch/Version: release-5.8.2
Describe the bug
I’m using an endpoint-level custom Go plugin in Tyk Gateway, and everything works as expected — but during startup, I see a confusing log error related to m.BaseMiddleware being nil.
Reproduction steps
Steps to reproduce the behavior:
My api definition

tyk_plugins.go

Logs (debug mode or log file):
time="Jul 17 12:16:31" level=error msg="Recovered from panic while loading Go-plugin" error="runtime error: invalid memory address or nil pointer dereference" mwPath=plugins/tyk_plugins.so mwSymbolName=ClearRate
Configuration (tyk config file):
tyk.conf.json
Configs from envs
API_LISTEN_PATH: "/local/"
API_URL: "http://httpbin"
TYK_GW_SECRET: "SECRET"
TYK_GW_APPPATH: "config/apps/"
TYK_GW_MIDDLEWAREPATH: "tyk/middleware/"
TYK_GW_POLICIES_POLICY_PATH: "tyk/middleware/"
TYK_GW_TEMPLATEPATH: "tyk-gw/templates"
TYK_GW_LOGLEVEL: "debug"
in the plugin loader code, I see the following lines in func (m *GoPluginMiddleware) loadPlugin() bool in mw_go_plugin.go:

At this point, m.BaseMiddleware is nil, which causes a log error during Tyk Gateway startup.
Behavior Observed
• The /clear endpoint is correctly handled by the plugin function (ClearRate).
• It does not proxy the request and returns a custom response (like a virtual endpoint), which is the desired behavior.
• However, during bootstrapping, Tyk logs an error related to m.BaseMiddleware.Copy() because m.BaseMiddleware is nil at that time.
Questions
1. Is it expected for BaseMiddleware to be nil for endpoint-level Go plugins (i.e., virtual endpoint-like behavior)?
2. If m.BaseMiddleware is not required in this case, should Tyk avoid calling .Copy() or initializing successHandler altogether?
3. Can this log error be suppressed or handled more gracefully when the plugin is not using BaseMiddleware?