Fix incorrect slog.Error usage for 4xx auth failures in gateway_internal.go
@dushaniw is already working on this.
Since Mar 16, 2026.
- Dominant language
- Go
- Stars
- 71
- Forks
- 111
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 110
Description
Summary
In platform-api/src/internal/handler/gateway_internal.go, the handlers GetSubscriptions, GetSubscriptionPlans, and GetMCPProxy currently use slog.Error for expected client-side authentication failures (4xx responses), which is inconsistent with the established convention.
Expected Behavior
Per the codebase convention, slog.Warn should be used for expected client errors (4xx responses such as missing/invalid API keys, unauthorized access, bad requests). slog.Error should be reserved for unexpected server-side failures (5xx responses).
The new authenticateRequest helper introduced in #1337 already follows this convention correctly.
Affected Handlers
GetSubscriptions— usesslog.Errorfor missing API key and authentication failure (4xx)GetSubscriptionPlans— usesslog.Errorfor missing API key and authentication failure (4xx)GetMCPProxy— usesslog.Errorfor missing API key and authentication failure (4xx)
Fix
Change the above slog.Error calls to slog.Warn for the 4xx auth failure branches in those three handlers, consistent with how authenticateRequest handles them.
References
- PR: https://github.com/wso2/api-platform/pull/1337
- Comment: https://github.com/wso2/api-platform/pull/1337#discussion_r2930592461
- Requested by: @dushaniw
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.