From 628d135359f83795f58881f91881f2fb3d7a4b70 Mon Sep 17 00:00:00 2001 From: SAY-5 Date: Sat, 2 May 2026 12:15:27 -0700 Subject: [PATCH 1/2] openapi: reject empty multipart class discriminator instead of slice-panic Signed-off-by: SAY-5 --- client.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client.go b/client.go index 41c7f397..4c537066 100644 --- a/client.go +++ b/client.go @@ -253,6 +253,14 @@ func getContentID(v reflect.Value, ref string, class string) (contentID string, if i := strings.IndexRune(fieldName, '-'); i != -1 { fieldName = fieldName[:i] } + // `fieldName` is client-controllable through a multipart class + // discriminator (e.g. n2InformationClass). An empty string ("") or a + // value starting with '-' would leave us slicing a zero-length string + // at fieldName[:1] / fieldName[1:] and panicked the multipart parse + // path on every SBI request that uses such a tag (#1039). + if len(fieldName) == 0 { + return "", fmt.Errorf("getContentID: empty class discriminator value") + } fieldName = fieldName[:1] + strings.ToLower(fieldName[1:]) + "Info" recursiveVal = lastVal.FieldByName(fieldName) if recursiveVal.Kind() == reflect.Ptr { From cb55c9ba8b8cf02e143e4d8404cf4c8b6c2e3038 Mon Sep 17 00:00:00 2001 From: SAY-5 Date: Wed, 6 May 2026 04:55:25 -0700 Subject: [PATCH 2/2] address review: trim inline comments per maintainer feedback Signed-off-by: SAY-5 --- client.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/client.go b/client.go index 4c537066..ed3309e6 100644 --- a/client.go +++ b/client.go @@ -253,11 +253,6 @@ func getContentID(v reflect.Value, ref string, class string) (contentID string, if i := strings.IndexRune(fieldName, '-'); i != -1 { fieldName = fieldName[:i] } - // `fieldName` is client-controllable through a multipart class - // discriminator (e.g. n2InformationClass). An empty string ("") or a - // value starting with '-' would leave us slicing a zero-length string - // at fieldName[:1] / fieldName[1:] and panicked the multipart parse - // path on every SBI request that uses such a tag (#1039). if len(fieldName) == 0 { return "", fmt.Errorf("getContentID: empty class discriminator value") }