diff --git a/source/sessions/snapshot-sessions.md b/source/sessions/snapshot-sessions.md index 76b984db72..e08e358fb3 100644 --- a/source/sessions/snapshot-sessions.md +++ b/source/sessions/snapshot-sessions.md @@ -137,7 +137,8 @@ class ClientSession { } ``` -Getting the value of `snapshotTime` on a non-snapshot session MUST raise an error. +The `snapshotTime` field MUST be read-only; in APIs that expose `snapshotTime` with a getter, attempting to read it on a +non-snapshot session MUST raise an error. Transactions are not allowed with snapshot sessions. Calling `session.startTransaction(options)` on a snapshot session MUST raise an error. @@ -270,6 +271,7 @@ C# driver will provide the reference implementation. The corresponding ticket is ## Changelog +- 2025-12-17: Clarify snapshotTime semantics: the field is either read-only or validated. - 2025-09-23: Exposed snapshotTime to applications. - 2024-05-08: Migrated from reStructuredText to Markdown. - 2021-06-15: Initial version. diff --git a/source/sessions/tests/README.md b/source/sessions/tests/README.md index 69e46e8142..3c3aa3fd01 100644 --- a/source/sessions/tests/README.md +++ b/source/sessions/tests/README.md @@ -270,10 +270,20 @@ Snapshot sessions tests require server of version 5.0 or higher and replica set Snapshot sessions tests require server of version 5.0 or higher and replica set or a sharded cluster deployment. -- Start a session by calling `startSession` on with `snapshot = false`. +- Start a session by calling `startSession` with `snapshot = false`. + +Drivers SHOULD implement one of the following approaches: + +**Approach 1: Validation (preferred if idiomatic)** + - Try to access the session's snapshot time. - Assert that a client side error was raised. +**Approach 2: Ensure Read-Only (if error-returning getters are not idiomatic)** + +- Attempt to mutate the session's `snapshotTime` field through any publicly accessible API. +- Assert that the original session's `snapshotTime` remains unchanged. + ## Changelog - 2025-09-25: Added tests for snapshotTime.