wso2 / wso2/api-platform

Fix incorrect slog.Error usage for 4xx auth failures in gateway_internal.go

Open
#1,360 0 comments 0 reactions 1 assignee View on GitHub

@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 — uses slog.Error for missing API key and authentication failure (4xx)
  • GetSubscriptionPlans — uses slog.Error for missing API key and authentication failure (4xx)
  • GetMCPProxy — uses slog.Error for 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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.