This is an automated email from the ASF dual-hosted git repository. hsluoyz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/casbin-gateway.git
commit b8d2736c07094414f5df40f61670422b650603cb Author: Yang Luo <[email protected]> AuthorDate: Fri Sep 25 18:50:29 2026 +0800 fix(probe): stop counting a smaller sibling model as the one asked for --- object/provider_probe_checks.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/object/provider_probe_checks.go b/object/provider_probe_checks.go index 53ed05d..8170b33 100644 --- a/object/provider_probe_checks.go +++ b/object/provider_probe_checks.go @@ -27,6 +27,7 @@ import ( "fmt" "math" "net/http" + "regexp" "sort" "strconv" "strings" @@ -447,6 +448,10 @@ func probeIdentityCheck(probeCase *ProbeCase, provider *Provider, asked string, return check } +// snapshotSuffix is what may separate two names of one model: a date, a +// Bedrock or Vertex version, or "latest". "-mini" or "-4-5" is another model. +var snapshotSuffix = regexp.MustCompile(`^[-@](\d{4}(-?\d{2}-?\d{2})?|latest|v\d+(:\d+)?)$`) + // sameModelName treats a name that only adds a version or date suffix as the // same model, which is what a vendor answering "claude-opus-4-5-20251101" to a // request for "claude-opus-4-5" is doing. @@ -463,7 +468,16 @@ func sameModelName(asked string, answered string) bool { if index := strings.LastIndex(right, "/"); index >= 0 { right = right[index+1:] } - return strings.HasPrefix(left, right) || strings.HasPrefix(right, left) + if left == right { + return true + } + if strings.HasPrefix(right, left) { + return snapshotSuffix.MatchString(right[len(left):]) + } + if strings.HasPrefix(left, right) { + return snapshotSuffix.MatchString(left[len(right):]) + } + return false } // probeVendorUndocumented is what the header case reports when there is no --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
