Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions packages/auth/pkg/auth/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ func (a *CommonAuthenticator[T]) GetHeaderKeysFromRequest(req *http.Request) (st
func (a *CommonAuthenticator[T]) Authenticate(ctx context.Context, ginCtx *gin.Context, input *openapi3filter.AuthenticationInput) error {
headerKey, err := a.GetHeaderKeysFromRequest(input.RequestValidationInput.Request)
if err != nil {
telemetry.ReportError(ctx,
"authorization header is missing",
err,
attribute.String("error.message", a.ErrorMessage),
)
if !errors.Is(err, ErrNoAuthHeader) {
telemetry.ReportError(ctx,
"authorization header is missing",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Telemetry message misleading after conditional skip

Low Severity

The telemetry.ReportError message "authorization header is missing" now only fires for ErrInvalidAuthHeader (malformed header), since ErrNoAuthHeader is explicitly excluded by the new guard. The telemetry event description no longer matches the actual error condition — it will misleadingly report "missing" when the header was present but malformed.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1c01dff. Configure here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The telemetry message "authorization header is missing" is incorrect because the preceding check ensures the error is not ErrNoAuthHeader. The message should be updated to "authorization header is invalid" to correctly reflect the state when ErrInvalidAuthHeader is returned.

Suggested change
"authorization header is missing",
"authorization header is invalid",

err,
attribute.String("error.message", a.ErrorMessage),
)
}

ginCtx.Status(http.StatusUnauthorized)

Expand Down
Loading