test: cover string user ids in workbench payloads

This commit is contained in:
richjohnrambo
2026-09-16 18:05:26 +08:00
parent 903a77f2c5
commit fc246c3086
3 changed files with 85 additions and 13 deletions
+1 -7
View File
@@ -27,8 +27,6 @@ type optionalUserID struct {
func (id *optionalUserID) UnmarshalJSON(raw []byte) error {
if strings.TrimSpace(string(raw)) == "null" {
id.set = true
id.value = 0
return nil
}
value, err := parseUserIDJSON(raw)
@@ -52,11 +50,7 @@ func parseUserIDJSON(raw []byte) (int64, error) {
if err := json.Unmarshal(raw, &text); err == nil {
return parseUserID(text)
}
var number int64
if err := json.Unmarshal(raw, &number); err == nil {
return number, nil
}
return 0, fmt.Errorf("invalid user id")
return 0, fmt.Errorf("user id must be a string")
}
func parseUserID(value string) (int64, error) {