Skip to content

Commit 7fb8c84

Browse files
authored
CXX-2995 Bump minimum required C Driver version to 1.29.0 (#1275)
* Address -Wdeprecated-declarations warnings for bson_as_json * Address -Wdeprecated-declarations warnings using recommended alternatives * Update release instructions with instant Augmented SBOM update * Update SBOM files with latest dependencies * Refactor client-side error detection in unified test runner * Add entry for rewrapManyDataKey-encrypt_failure client-side errors * Add instruction to schedule C Driver version updates in JIRA
1 parent 3d14de5 commit 7fb8c84

File tree

11 files changed

+123
-67
lines changed

11 files changed

+123
-67
lines changed

.evergreen/config_generator/components/funcs/install_c_driver.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
# - the version of pkg:github/mongodb/mongo-c-driver in etc/purls.txt
1313
# - the default value of --c-driver-build-ref in etc/make_release.py
1414
# Only LIBMONGOC_DOWNLOAD_VERSION needs to be updated when pinning to an unreleased commit.
15-
MONGOC_VERSION_MINIMUM = '1.28.0'
15+
# If pinning to an unreleased commit, create a "Blocked" JIRA ticket with
16+
# a "depends on" link to the appropriate C Driver version release ticket.
17+
MONGOC_VERSION_MINIMUM = '1.29.0'
1618

1719

1820
class InstallCDriver(Function):

.evergreen/generated_configs/functions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ functions:
307307
type: setup
308308
params:
309309
updates:
310-
- { key: mongoc_version_minimum, value: 1.28.0 }
310+
- { key: mongoc_version_minimum, value: 1.29.0 }
311311
- command: subprocess.exec
312312
type: setup
313313
params:

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Changes prior to 3.9.0 are documented as [release notes on GitHub](https://githu
1515

1616
## Changed
1717

18+
- Bump the minimum required C Driver version to [1.29.0](https://github.com/mongodb/mongo-c-driver/releases/tag/1.29.0).
1819
- CMake option `ENABLE_TESTS` is now `OFF` by default.
1920
- Set `ENABLE_TEST=ON` to re-enable building test targets.
2021
- Set `BUILD_TESTING=ON` to include test targets in the "all" target when `ENABLE_TESTS=ON` (since 3.9.0, `OFF` by default).

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ else()
4949
endif()
5050

5151
# Also update etc/purls.txt.
52-
set(LIBBSON_REQUIRED_VERSION 1.28.0)
52+
set(LIBBSON_REQUIRED_VERSION 1.29.0)
5353
set(LIBBSON_REQUIRED_ABI_VERSION 1.0)
5454

5555
# Also update etc/purls.txt.
56-
set(LIBMONGOC_REQUIRED_VERSION 1.28.0)
57-
set(LIBMONGOC_DOWNLOAD_VERSION d934cd5de55af65220816e4fd01ce3f9c0ef1cd4) # TODO: update to 1.29.0 once it is released.
56+
set(LIBMONGOC_REQUIRED_VERSION 1.29.0)
57+
set(LIBMONGOC_DOWNLOAD_VERSION 1.29.0)
5858
set(LIBMONGOC_REQUIRED_ABI_VERSION 1.0)
5959

6060
set(NEED_DOWNLOAD_C_DRIVER false)

etc/augmented.sbom.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"components": [
33
{
4-
"bom-ref": "pkg:github/mongodb/mongo-c-driver@v1.28.0",
4+
"bom-ref": "pkg:github/mongodb/mongo-c-driver@v1.29.0",
55
"copyright": "Copyright 2009-present MongoDB, Inc.",
66
"externalReferences": [
77
{
88
"type": "distribution",
9-
"url": "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/v1.28.0.tar.gz"
9+
"url": "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/v1.29.0.tar.gz"
1010
},
1111
{
1212
"type": "website",
13-
"url": "https://github.com/mongodb/mongo-c-driver/tree/v1.28.0"
13+
"url": "https://github.com/mongodb/mongo-c-driver/tree/v1.29.0"
1414
}
1515
],
1616
"group": "mongodb",
@@ -22,18 +22,18 @@
2222
}
2323
],
2424
"name": "mongo-c-driver",
25-
"purl": "pkg:github/mongodb/mongo-c-driver@v1.28.0",
25+
"purl": "pkg:github/mongodb/mongo-c-driver@v1.29.0",
2626
"type": "library",
27-
"version": "v1.28.0"
27+
"version": "v1.29.0"
2828
}
2929
],
3030
"dependencies": [
3131
{
32-
"ref": "pkg:github/mongodb/mongo-c-driver@v1.28.0"
32+
"ref": "pkg:github/mongodb/mongo-c-driver@v1.29.0"
3333
}
3434
],
3535
"metadata": {
36-
"timestamp": "2024-11-04T17:45:42.970888+00:00",
36+
"timestamp": "2024-11-19T18:14:12.160074+00:00",
3737
"tools": [
3838
{
3939
"externalReferences": [
@@ -77,7 +77,7 @@
7777
]
7878
},
7979
"serialNumber": "urn:uuid:dd68fbb0-f77c-4bb9-90cd-606dd854f301",
80-
"version": 4,
80+
"version": 5,
8181
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
8282
"bomFormat": "CycloneDX",
8383
"specVersion": "1.5",

etc/cyclonedx.sbom.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"components": [
33
{
4-
"bom-ref": "pkg:github/mongodb/mongo-c-driver@v1.28.0",
4+
"bom-ref": "pkg:github/mongodb/mongo-c-driver@v1.29.0",
55
"copyright": "Copyright 2009-present MongoDB, Inc.",
66
"externalReferences": [
77
{
88
"type": "distribution",
9-
"url": "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/v1.28.0.tar.gz"
9+
"url": "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/v1.29.0.tar.gz"
1010
},
1111
{
1212
"type": "website",
13-
"url": "https://github.com/mongodb/mongo-c-driver/tree/v1.28.0"
13+
"url": "https://github.com/mongodb/mongo-c-driver/tree/v1.29.0"
1414
}
1515
],
1616
"group": "mongodb",
@@ -22,18 +22,18 @@
2222
}
2323
],
2424
"name": "mongo-c-driver",
25-
"purl": "pkg:github/mongodb/mongo-c-driver@v1.28.0",
25+
"purl": "pkg:github/mongodb/mongo-c-driver@v1.29.0",
2626
"type": "library",
27-
"version": "v1.28.0"
27+
"version": "v1.29.0"
2828
}
2929
],
3030
"dependencies": [
3131
{
32-
"ref": "pkg:github/mongodb/mongo-c-driver@v1.28.0"
32+
"ref": "pkg:github/mongodb/mongo-c-driver@v1.29.0"
3333
}
3434
],
3535
"metadata": {
36-
"timestamp": "2024-11-04T17:45:42.970888+00:00",
36+
"timestamp": "2024-11-19T18:14:12.160074+00:00",
3737
"tools": [
3838
{
3939
"externalReferences": [
@@ -77,7 +77,7 @@
7777
]
7878
},
7979
"serialNumber": "urn:uuid:dd68fbb0-f77c-4bb9-90cd-606dd854f301",
80-
"version": 4,
80+
"version": 5,
8181
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
8282
"bomFormat": "CycloneDX",
8383
"specVersion": "1.5",

etc/make_release.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
show_default=True,
8989
help='The remote reference which points to the mongodb/mongo-cxx-driver repo')
9090
@click.option('--c-driver-build-ref',
91-
default='1.28.0',
91+
default='1.29.0',
9292
show_default=True,
9393
help='When building the C driver, build at this Git reference')
9494
@click.option('--with-c-driver',

etc/purls.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# re-generate the SBOM JSON file!
77

88
# libbson and libmongoc are obtained via cmake/FetchMongoC.cmake.
9-
pkg:github/mongodb/mongo-c-driver@v1.28.0
9+
pkg:github/mongodb/mongo-c-driver@v1.29.0

etc/releasing.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ Generate an updated Augmented SBOM as described below.
160160

161161
Ensure the `silk-check-augmented-sbom` task is passing on Evergreen for the relevant release branch. If it is passing, nothing needs to be done (unless the SBOM Lite was updated as described above).
162162

163-
If the `silk-check-augmented-sbom` task was failing, update the Augmented SBOM document using the following command(s):
163+
#### Regular Update
164+
165+
Update the Augmented SBOM document using the following command(s):
164166

165167
```bash
166168
# Artifactory and Silk credentials.
@@ -189,6 +191,44 @@ Update `etc/third_party_vulnerabilities.md` with any updates to new or known vul
189191

190192
Commit the latest version of the Augmented SBOM document into the repo as `etc/augmented.sbom.json`. The Augmented SBOM document does not need to be updated if the `silk-check-augmented-sbom` was not failing (in which case the only changes present would a version bump or timestamp update).
191193

194+
#### Instant Update
195+
196+
If the Augmented SBOM has not yet been updated in time for a release, a temporary Silk Asset Group may be used instead:
197+
198+
```bash
199+
# Artifactory and Silk credentials.
200+
. $HOME/.secrets/artifactory-creds.txt
201+
. $HOME/.secrets/silk-creds.txt
202+
203+
# Name of the temporary Silk Asset Group. Do NOT use an existing Silk Asset Group!
204+
asset_group_id="mongo-cxx-driver-X.Y.Z-tmp"
205+
206+
# Output: "Login succeeded!"
207+
podman login --password-stdin --username "${ARTIFACTORY_USER:?}" artifactory.corp.mongodb.com <<<"${ARTIFACTORY_PASSWORD:?}"
208+
209+
# Ensure latest version of SilkBomb is being used.
210+
podman pull artifactory.corp.mongodb.com/release-tools-container-registry-public-local/silkbomb:1.0
211+
212+
# Common flags to podman.
213+
silkbomb_flags=(
214+
--env-file "$HOME/.secrets/silk-creds.txt"
215+
-it --rm -v "$(pwd):/pwd"
216+
artifactory.corp.mongodb.com/release-tools-container-registry-public-local/silkbomb:1.0
217+
)
218+
219+
# Create a new and temporary Silk Asset Group.
220+
podman run "${silkbomb_flags[@]:?}" asset-group --asset-cmd create --silk-asset-group "${asset_group_id:?}" --name "${asset_group_id:?}"
221+
222+
# Upload the SBOM Lite.
223+
podman run "${silkbomb_flags[@]:?}" upload --silk-asset-group "${asset_group_id:?}" -i /pwd/etc/cyclonedx.sbom.json -o /pwd/etc/cyclonedx.sbom.json
224+
225+
# Download the Augmented SBOM.
226+
podman run "${silkbomb_flags[@]:?}" download --silk-asset-group "${asset_group_id:?}" -o /pwd/etc/augmented.sbom.json
227+
228+
# Remove the temporary Silk Asset Group.
229+
podman run "${silkbomb_flags[@]:?}" asset-group --asset-cmd delete --silk-asset-group "${asset_group_id:?}"
230+
```
231+
192232
### Check Snyk
193233

194234
Inspect the list of projects in the latest report for the `mongodb/mongo-cxx-driver` target in [Snyk](https://app.snyk.io/org/dev-prod/).

src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/json.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void bson_free_deleter(std::uint8_t* ptr) {
3636
bson_free(ptr);
3737
}
3838

39-
std::string to_json_helper(document::view view, decltype(bson_as_json) converter) {
39+
std::string to_json_helper(document::view view, decltype(bson_as_legacy_extended_json) converter) {
4040
bson_t bson;
4141

4242
if (!bson_init_static(&bson, view.data(), view.length())) {
@@ -61,7 +61,7 @@ std::string to_json_helper(document::view view, decltype(bson_as_json) converter
6161
std::string to_json(document::view view, ExtendedJsonMode mode) {
6262
switch (mode) {
6363
case ExtendedJsonMode::k_legacy:
64-
return to_json_helper(view, bson_as_json);
64+
return to_json_helper(view, bson_as_legacy_extended_json);
6565

6666
case ExtendedJsonMode::k_relaxed:
6767
return to_json_helper(view, bson_as_relaxed_extended_json);
@@ -76,7 +76,7 @@ std::string to_json(document::view view, ExtendedJsonMode mode) {
7676
std::string to_json(array::view view, ExtendedJsonMode mode) {
7777
switch (mode) {
7878
case ExtendedJsonMode::k_legacy:
79-
return to_json_helper(view, bson_array_as_json);
79+
return to_json_helper(view, bson_array_as_legacy_extended_json);
8080

8181
case ExtendedJsonMode::k_relaxed:
8282
return to_json_helper(view, bson_array_as_relaxed_extended_json);

src/mongocxx/test/spec/unified_tests/runner.cpp

Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -866,46 +866,59 @@ void assert_error(const mongocxx::operation_exception& exception,
866866
}
867867

868868
if (const auto is_client_error = expect_error["isClientError"]) {
869-
if (std::strstr(exception.what(), "Snapshot reads require MongoDB 5.0 or later") !=
870-
nullptr) {
871-
// Original error: { MONGOC_ERROR_CLIENT, MONGOC_ERROR_CLIENT_SESSION_FAILURE }
872-
// Do not assert a server-side error.
873-
// The C++ driver throws this error as a server-side error operation_exception.
874-
// Remove this special case as part of CXX-2377.
875-
REQUIRE(is_client_error.get_bool());
876-
} else if (std::strstr(exception.what(), "The selected server does not support hint for") !=
877-
nullptr) {
878-
// Original error: { MONGOC_ERROR_COMMAND, MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION }
879-
// Do not assert a server-side error.
880-
// The C++ driver throws this error as a server-side error operation_exception.
881-
// Remove this special case as part of CXX-2377.
882-
REQUIRE(is_client_error.get_bool());
883-
} else if (std::strstr(exception.what(), "Error in KMS response") != nullptr) {
884-
REQUIRE(is_client_error.get_bool());
885-
} else if (std::strstr(exception.what(),
886-
"keyMaterial should have length 96, but has length 84") != nullptr) {
887-
REQUIRE(is_client_error.get_bool());
888-
} else if (std::strstr(exception.what(), "expected UTF-8 key") != nullptr) {
889-
REQUIRE(is_client_error.get_bool());
890-
} else if (std::strstr(exception.what(), "Unexpected field: 'invalid'") != nullptr) {
891-
REQUIRE(is_client_error.get_bool());
892-
} else if (std::strstr(exception.what(), "Failed to resolve kms.invalid.amazonaws.com") !=
893-
nullptr) {
894-
REQUIRE(is_client_error.get_bool());
895-
} else if (std::strstr(
896-
exception.what(),
897-
"The ciphertext refers to a customer master key that does not exist") !=
898-
nullptr) {
899-
REQUIRE(is_client_error.get_bool());
900-
} else if (std::strstr(exception.what(), "does not exist") != nullptr) {
901-
REQUIRE(is_client_error.get_bool());
902-
} else if (std::strstr(exception.what(),
903-
"Failed to resolve invalid-vault-csfle.vault.azure.net") !=
904-
nullptr) {
905-
REQUIRE(is_client_error.get_bool());
906-
} else if (is_client_error.get_bool()) {
907-
// An operation_exception represents a server-side error.
908-
REQUIRE(!is_client_error.get_bool());
869+
// An explicit list of client-side errors. We do not yet have a reliable and consistent
870+
// method to distinguish client-side errors from server-side errors. (CXX-2377)
871+
static const bsoncxx::stdx::string_view patterns[] = {
872+
// { MONGOC_ERROR_CLIENT, MONGOC_ERROR_CLIENT_SESSION_FAILURE }
873+
// mongoc: mongoc_cmd_parts_assemble
874+
"Snapshot reads require MongoDB 5.0 or later",
875+
876+
// { MONGOC_ERROR_COMMAND, MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION }
877+
// mongoc: mongoc_collection_find_and_modify_with_opts,
878+
// _mongoc_write_command_execute_idl
879+
"The selected server does not support hint for",
880+
881+
// { MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_NAME_RESOLUTION }
882+
// mongoc: mongoc_client_connect_tcp, mongoc_topology_scanner_node_setup_tcp
883+
"Failed to resolve ",
884+
885+
// { MONGOCRYPT_STATUS_ERROR_CLIENT, MONGOCRYPT_GENERIC_ERROR_CODE }
886+
// libmongocrypt: mongocrypt_kms_ctx_feed
887+
"Error in KMS response",
888+
889+
// { MONGOCRYPT_STATUS_ERROR_CLIENT, MONGOCRYPT_GENERIC_ERROR_CODE }
890+
// libmongocrypt: mongocrypt_ctx_setopt_key_material
891+
"keyMaterial should have length 96, but has length 84",
892+
893+
// { MONGOCRYPT_STATUS_ERROR_CLIENT, MONGOCRYPT_GENERIC_ERROR_CODE }
894+
// libmongocrypt: _mongocrypt_parse_optional_utf8, _mongocrypt_parse_required_utf8
895+
"expected UTF-8 key",
896+
897+
// { MONGOCRYPT_STATUS_ERROR_CLIENT, MONGOCRYPT_GENERIC_ERROR_CODE }
898+
// libmongocrypt: _mongocrypt_check_allowed_fields
899+
"Unexpected field: 'invalid'",
900+
901+
// { MONGOCRYPT_STATUS_ERROR_CLIENT, MONGOCRYPT_GENERIC_ERROR_CODE }
902+
// libmongocrypt: _kms_done
903+
"key material not expected length",
904+
};
905+
906+
const bsoncxx::stdx::string_view message = exception.what();
907+
908+
const auto iter = std::find_if(std::begin(patterns),
909+
std::end(patterns),
910+
[message](bsoncxx::stdx::string_view pattern) {
911+
return message.find(pattern) != message.npos;
912+
});
913+
914+
if (iter != std::end(patterns)) {
915+
// Treat this as a client-side error.
916+
const auto pattern = *iter;
917+
CAPTURE(pattern);
918+
REQUIRE(is_client_error.get_bool().value);
919+
} else {
920+
// Treat this as a server-side error.
921+
REQUIRE(!is_client_error.get_bool().value);
909922
}
910923
}
911924

0 commit comments

Comments
 (0)