From bf20c6bbd37e133b09daed08281010e0c04b2273 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Tue, 21 Oct 2025 17:49:17 -0700 Subject: [PATCH] Fix CheckScimError to use errors.As() for wrapped error support This allows ScimError to be properly detected even when wrapped with error tracing libraries like errtrace, which is important for correct HTTP status code handling. --- errors/error.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/errors/error.go b/errors/error.go index fac0643..e7204e3 100644 --- a/errors/error.go +++ b/errors/error.go @@ -2,6 +2,7 @@ package errors import ( "encoding/json" + "errors" "fmt" "net/http" "strconv" @@ -132,9 +133,10 @@ type ScimError struct { } // CheckScimError checks whether the error's status code is defined by SCIM for the given HTTP method. +// Uses errors.As to support wrapped errors (Go 1.13+). func CheckScimError(err error, method string) ScimError { - scimErr, ok := err.(ScimError) - if !ok { + var scimErr ScimError + if !errors.As(err, &scimErr) { return ScimError{ Detail: err.Error(), Status: http.StatusInternalServerError,