fix: accept stringified numeric response IDs (#1021)

This commit is contained in:
Dale Seo 2026-07-21 16:01:22 -04:00 • committed by GitHub
commit 8803d39034
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -240,6 +240,22 @@ impl NumberOrString {
NumberOrString::String(s) => Value::String(s.to_string()),
}
}
pub(crate) fn numeric_string_value(&self) -> Option<i64> {
match self {
Self::String(id) => id.parse().ok(),
Self::Number(_) => None,
}
}
pub(crate) fn matches_response_id(&self, response_id: &Self) -> bool {
self == response_id
|| matches!(
self,
Self::Number(request_id)
if response_id.numeric_string_value() == Some(*request_id)
)
}
}
impl std::fmt::Display for NumberOrString {