`call_graph_url()` serializes POSIXct body fields as ambiguous, offset-less datetime strings
まだ誰も着手していません。
評価
調査の方向性
R/call_graph.R の call_graph_url() から始め、POSIXct 値を使って issue に示されている JSON 出力を再現します。リクエストボディの値がどのようにシリアライズされるかを追跡し、POSIXct 値が末尾に Z の付いた UTC ISO 8601 文字列になり、Date 値が期待される日付形式を使用することを、ボディ内にネストされている場合も含めて確認します。
索引モデルが issue の本文から書いたものです。
説明
call_graph_url() serializes JSON request bodies with:
# R/call_graph.R, call_graph_url()
body <- jsonlite::toJSON(body[!null], auto_unbox = TRUE, digits = 22, null = "null")
This uses jsonlite's default POSIXt = "string" handling, which calls format()/as.character() on POSIXct values. That respects the object's tzone attribute but appends no UTC offset or "Z" suffix, so the resulting string is ambiguous about what instant it represents.
Microsoft Graph's OData Edm.DateTimeOffset fields expect an explicit ISO 8601 string with a Z or numeric offset (e.g. "2022-07-31T14:05:19Z"); sending a bare "2022-07-31 14:05:19" leaves Graph to guess the offset, which I think resolves against the site/tenant's regional timezone, silently shifting the stored instant away from the value the caller intended.
library(jsonlite)
x <- as.POSIXct(1659276319, origin = "1970-01-01", tz = "UTC")
# This mirrors call_graph_url()'s exact serialization call:
jsonlite::toJSON(
list(dateTimeField = x),
auto_unbox = TRUE,
digits = 22,
null = "null"
)
#> {"dateTimeField":"2022-07-31 14:05:19"}
# Confirming it's not just a formatting-style choice: jsonlite's "ISO8601"
# option has the same ambiguity, just with a "T" separator instead of a space
jsonlite::toJSON(list(dateTimeField = x), POSIXt = "ISO8601", auto_unbox = TRUE)
#> {"dateTimeField":"2022-07-31T14:05:19"}
# still no "Z"/offset
# The only unambiguous encoding requires explicit UTC formatting:
strftime(x, "%Y-%m-%dT%H:%M:%SZ", tz = "UTC")
#> [1] "2022-07-31T14:05:19Z"
Created on 2026-09-09 with reprex v2.1.1
Expected: A POSIXct value passed in a request body to call_graph_url() should serialize to an unambiguous ISO 8601 UTC string (...Z) matching what Graph's OData Edm.DateTimeOffset fields expect, regardless of the POSIXct object's tzone attribute or the caller's Sys.timezone().
Actual: The serialized string carries no UTC marker at all, so any Graph endpoint accepting a dateTime/DateTimeOffset field is handed an ambiguous value whenever a caller passes a native POSIXct.
Suggested fix: In call_graph_url(), before calling jsonlite::toJSON(), recursively convert any POSIXct (and Date) elements of body to explicit UTC ISO 8601 strings, e.g. strftime(x, "%Y-%m-%dT%H:%M:%SZ", tz = "UTC") for POSIXct and strftime(x, "%Y-%m-%d", tz = "UTC") for Date. Neither of jsonlite's built-in POSIXt options ("string", "ISO8601") is sufficient on their own, since neither appends a UTC offset.
- 主要言語
- R
- スター
- 38
- フォーク
- 22
- 平均マージ
- 2日 8時間
- マージ済み PR(30日)
- 1
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Azure/AzureGraph のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
Azure/AzureGraph#37 · コメント 1 件 ·
Azure/AzureGraph の issue をすべて見る
似ている issue
-
documentation pkg infrastructure
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
epiverse-trace/epiparameter#511 ·
-
function:write_dwc
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
Urgent request: Due to vulnerabilities move to API version 12.6.1 (12.6.2 eventually) or 13.1.1 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
jbkunst/highcharter#849 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
r-lib/pkgdepends#485 · コメント 3 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100