Accept equivalent integer references in model responses

This commit is contained in:
2026-11-17 04:22:20 +00:00
parent 2d93e8ae7c
commit 44c767f285
10 changed files with 52 additions and 27 deletions

View File

@@ -143,17 +143,7 @@ func extractSegments(raw []byte) (json.RawMessage, error) {
}
}
// sourceID decodes native integers without routing them through float64.
// Decimal and exponent spellings are accepted if they denote an exact integer.
type sourceID int
func (id *sourceID) UnmarshalJSON(raw []byte) error {
if value, ok := jsonnumber.Int(string(raw)); ok {
*id = sourceID(value)
return nil
}
return json.Unmarshal(raw, (*int)(id))
}
type sourceID = jsonnumber.Integer
func validateSourceSegments(segments []SourceSegment) error {
for i, s := range segments {