Skip to content

CXX-2995 Bump minimum required C Driver version to 1.29.0 #1275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
# - the version of pkg:github/mongodb/mongo-c-driver in etc/purls.txt
# - the default value of --c-driver-build-ref in etc/make_release.py
# Only LIBMONGOC_DOWNLOAD_VERSION needs to be updated when pinning to an unreleased commit.
MONGOC_VERSION_MINIMUM = '1.28.0'
# If pinning to an unreleased commit, create a "Blocked" JIRA ticket with
# a "depends on" link to the appropriate C Driver version release ticket.
MONGOC_VERSION_MINIMUM = '1.29.0'


class InstallCDriver(Function):
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/generated_configs/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ functions:
type: setup
params:
updates:
- { key: mongoc_version_minimum, value: 1.28.0 }
- { key: mongoc_version_minimum, value: 1.29.0 }
- command: subprocess.exec
type: setup
params:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Changes prior to 3.9.0 are documented as [release notes on GitHub](https://githu

## Changed

- Bump the minimum required C Driver version to [1.29.0](https://github.com/mongodb/mongo-c-driver/releases/tag/1.29.0).
- CMake option `ENABLE_TESTS` is now `OFF` by default.
- Set `ENABLE_TEST=ON` to re-enable building test targets.
- Set `BUILD_TESTING=ON` to include test targets in the "all" target when `ENABLE_TESTS=ON` (since 3.9.0, `OFF` by default).
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ else()
endif()

# Also update etc/purls.txt.
set(LIBBSON_REQUIRED_VERSION 1.28.0)
set(LIBBSON_REQUIRED_VERSION 1.29.0)
set(LIBBSON_REQUIRED_ABI_VERSION 1.0)

# Also update etc/purls.txt.
set(LIBMONGOC_REQUIRED_VERSION 1.28.0)
set(LIBMONGOC_DOWNLOAD_VERSION d934cd5de55af65220816e4fd01ce3f9c0ef1cd4) # TODO: update to 1.29.0 once it is released.
set(LIBMONGOC_REQUIRED_VERSION 1.29.0)
set(LIBMONGOC_DOWNLOAD_VERSION 1.29.0)
set(LIBMONGOC_REQUIRED_ABI_VERSION 1.0)

set(NEED_DOWNLOAD_C_DRIVER false)
Expand Down
16 changes: 8 additions & 8 deletions etc/augmented.sbom.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"components": [
{
"bom-ref": "pkg:github/mongodb/mongo-c-driver@v1.28.0",
"bom-ref": "pkg:github/mongodb/mongo-c-driver@v1.29.0",
"copyright": "Copyright 2009-present MongoDB, Inc.",
"externalReferences": [
{
"type": "distribution",
"url": "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/v1.28.0.tar.gz"
"url": "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/v1.29.0.tar.gz"
},
{
"type": "website",
"url": "https://github.com/mongodb/mongo-c-driver/tree/v1.28.0"
"url": "https://github.com/mongodb/mongo-c-driver/tree/v1.29.0"
}
],
"group": "mongodb",
Expand All @@ -22,18 +22,18 @@
}
],
"name": "mongo-c-driver",
"purl": "pkg:github/mongodb/mongo-c-driver@v1.28.0",
"purl": "pkg:github/mongodb/mongo-c-driver@v1.29.0",
"type": "library",
"version": "v1.28.0"
"version": "v1.29.0"
}
],
"dependencies": [
{
"ref": "pkg:github/mongodb/mongo-c-driver@v1.28.0"
"ref": "pkg:github/mongodb/mongo-c-driver@v1.29.0"
}
],
"metadata": {
"timestamp": "2024-11-04T17:45:42.970888+00:00",
"timestamp": "2024-11-19T18:14:12.160074+00:00",
"tools": [
{
"externalReferences": [
Expand Down Expand Up @@ -77,7 +77,7 @@
]
},
"serialNumber": "urn:uuid:dd68fbb0-f77c-4bb9-90cd-606dd854f301",
"version": 4,
"version": 5,
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
"bomFormat": "CycloneDX",
"specVersion": "1.5",
Expand Down
16 changes: 8 additions & 8 deletions etc/cyclonedx.sbom.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"components": [
{
"bom-ref": "pkg:github/mongodb/mongo-c-driver@v1.28.0",
"bom-ref": "pkg:github/mongodb/mongo-c-driver@v1.29.0",
"copyright": "Copyright 2009-present MongoDB, Inc.",
"externalReferences": [
{
"type": "distribution",
"url": "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/v1.28.0.tar.gz"
"url": "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/v1.29.0.tar.gz"
},
{
"type": "website",
"url": "https://github.com/mongodb/mongo-c-driver/tree/v1.28.0"
"url": "https://github.com/mongodb/mongo-c-driver/tree/v1.29.0"
}
],
"group": "mongodb",
Expand All @@ -22,18 +22,18 @@
}
],
"name": "mongo-c-driver",
"purl": "pkg:github/mongodb/mongo-c-driver@v1.28.0",
"purl": "pkg:github/mongodb/mongo-c-driver@v1.29.0",
"type": "library",
"version": "v1.28.0"
"version": "v1.29.0"
}
],
"dependencies": [
{
"ref": "pkg:github/mongodb/mongo-c-driver@v1.28.0"
"ref": "pkg:github/mongodb/mongo-c-driver@v1.29.0"
}
],
"metadata": {
"timestamp": "2024-11-04T17:45:42.970888+00:00",
"timestamp": "2024-11-19T18:14:12.160074+00:00",
"tools": [
{
"externalReferences": [
Expand Down Expand Up @@ -77,7 +77,7 @@
]
},
"serialNumber": "urn:uuid:dd68fbb0-f77c-4bb9-90cd-606dd854f301",
"version": 4,
"version": 5,
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
"bomFormat": "CycloneDX",
"specVersion": "1.5",
Expand Down
2 changes: 1 addition & 1 deletion etc/make_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
show_default=True,
help='The remote reference which points to the mongodb/mongo-cxx-driver repo')
@click.option('--c-driver-build-ref',
default='1.28.0',
default='1.29.0',
show_default=True,
help='When building the C driver, build at this Git reference')
@click.option('--with-c-driver',
Expand Down
2 changes: 1 addition & 1 deletion etc/purls.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# re-generate the SBOM JSON file!

# libbson and libmongoc are obtained via cmake/FetchMongoC.cmake.
pkg:github/mongodb/mongo-c-driver@v1.28.0
pkg:github/mongodb/mongo-c-driver@v1.29.0
42 changes: 41 additions & 1 deletion etc/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ Generate an updated Augmented SBOM as described below.

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).

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

Update the Augmented SBOM document using the following command(s):

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

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).

#### Instant Update

If the Augmented SBOM has not yet been updated in time for a release, a temporary Silk Asset Group may be used instead:

```bash
# Artifactory and Silk credentials.
. $HOME/.secrets/artifactory-creds.txt
. $HOME/.secrets/silk-creds.txt

# Name of the temporary Silk Asset Group. Do NOT use an existing Silk Asset Group!
asset_group_id="mongo-cxx-driver-X.Y.Z-tmp"

# Output: "Login succeeded!"
podman login --password-stdin --username "${ARTIFACTORY_USER:?}" artifactory.corp.mongodb.com <<<"${ARTIFACTORY_PASSWORD:?}"

# Ensure latest version of SilkBomb is being used.
podman pull artifactory.corp.mongodb.com/release-tools-container-registry-public-local/silkbomb:1.0

# Common flags to podman.
silkbomb_flags=(
--env-file "$HOME/.secrets/silk-creds.txt"
-it --rm -v "$(pwd):/pwd"
artifactory.corp.mongodb.com/release-tools-container-registry-public-local/silkbomb:1.0
)

# Create a new and temporary Silk Asset Group.
podman run "${silkbomb_flags[@]:?}" asset-group --asset-cmd create --silk-asset-group "${asset_group_id:?}" --name "${asset_group_id:?}"

# Upload the SBOM Lite.
podman run "${silkbomb_flags[@]:?}" upload --silk-asset-group "${asset_group_id:?}" -i /pwd/etc/cyclonedx.sbom.json -o /pwd/etc/cyclonedx.sbom.json

# Download the Augmented SBOM.
podman run "${silkbomb_flags[@]:?}" download --silk-asset-group "${asset_group_id:?}" -o /pwd/etc/augmented.sbom.json

# Remove the temporary Silk Asset Group.
podman run "${silkbomb_flags[@]:?}" asset-group --asset-cmd delete --silk-asset-group "${asset_group_id:?}"
```

### Check Snyk

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/).
Expand Down
6 changes: 3 additions & 3 deletions src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void bson_free_deleter(std::uint8_t* ptr) {
bson_free(ptr);
}

std::string to_json_helper(document::view view, decltype(bson_as_json) converter) {
std::string to_json_helper(document::view view, decltype(bson_as_legacy_extended_json) converter) {
bson_t bson;

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

case ExtendedJsonMode::k_relaxed:
return to_json_helper(view, bson_as_relaxed_extended_json);
Expand All @@ -76,7 +76,7 @@ std::string to_json(document::view view, ExtendedJsonMode mode) {
std::string to_json(array::view view, ExtendedJsonMode mode) {
switch (mode) {
case ExtendedJsonMode::k_legacy:
return to_json_helper(view, bson_array_as_json);
return to_json_helper(view, bson_array_as_legacy_extended_json);

case ExtendedJsonMode::k_relaxed:
return to_json_helper(view, bson_array_as_relaxed_extended_json);
Expand Down
93 changes: 53 additions & 40 deletions src/mongocxx/test/spec/unified_tests/runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,46 +866,59 @@ void assert_error(const mongocxx::operation_exception& exception,
}

if (const auto is_client_error = expect_error["isClientError"]) {
if (std::strstr(exception.what(), "Snapshot reads require MongoDB 5.0 or later") !=
nullptr) {
// Original error: { MONGOC_ERROR_CLIENT, MONGOC_ERROR_CLIENT_SESSION_FAILURE }
// Do not assert a server-side error.
// The C++ driver throws this error as a server-side error operation_exception.
// Remove this special case as part of CXX-2377.
REQUIRE(is_client_error.get_bool());
} else if (std::strstr(exception.what(), "The selected server does not support hint for") !=
nullptr) {
// Original error: { MONGOC_ERROR_COMMAND, MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION }
// Do not assert a server-side error.
// The C++ driver throws this error as a server-side error operation_exception.
// Remove this special case as part of CXX-2377.
REQUIRE(is_client_error.get_bool());
} else if (std::strstr(exception.what(), "Error in KMS response") != nullptr) {
REQUIRE(is_client_error.get_bool());
} else if (std::strstr(exception.what(),
"keyMaterial should have length 96, but has length 84") != nullptr) {
REQUIRE(is_client_error.get_bool());
} else if (std::strstr(exception.what(), "expected UTF-8 key") != nullptr) {
REQUIRE(is_client_error.get_bool());
} else if (std::strstr(exception.what(), "Unexpected field: 'invalid'") != nullptr) {
REQUIRE(is_client_error.get_bool());
} else if (std::strstr(exception.what(), "Failed to resolve kms.invalid.amazonaws.com") !=
nullptr) {
REQUIRE(is_client_error.get_bool());
} else if (std::strstr(
exception.what(),
"The ciphertext refers to a customer master key that does not exist") !=
nullptr) {
REQUIRE(is_client_error.get_bool());
} else if (std::strstr(exception.what(), "does not exist") != nullptr) {
REQUIRE(is_client_error.get_bool());
} else if (std::strstr(exception.what(),
"Failed to resolve invalid-vault-csfle.vault.azure.net") !=
nullptr) {
REQUIRE(is_client_error.get_bool());
} else if (is_client_error.get_bool()) {
// An operation_exception represents a server-side error.
REQUIRE(!is_client_error.get_bool());
// An explicit list of client-side errors. We do not yet have a reliable and consistent
// method to distinguish client-side errors from server-side errors. (CXX-2377)
static const bsoncxx::stdx::string_view patterns[] = {
// { MONGOC_ERROR_CLIENT, MONGOC_ERROR_CLIENT_SESSION_FAILURE }
// mongoc: mongoc_cmd_parts_assemble
"Snapshot reads require MongoDB 5.0 or later",

// { MONGOC_ERROR_COMMAND, MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION }
// mongoc: mongoc_collection_find_and_modify_with_opts,
// _mongoc_write_command_execute_idl
"The selected server does not support hint for",

// { MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_NAME_RESOLUTION }
// mongoc: mongoc_client_connect_tcp, mongoc_topology_scanner_node_setup_tcp
"Failed to resolve ",

// { MONGOCRYPT_STATUS_ERROR_CLIENT, MONGOCRYPT_GENERIC_ERROR_CODE }
// libmongocrypt: mongocrypt_kms_ctx_feed
"Error in KMS response",

// { MONGOCRYPT_STATUS_ERROR_CLIENT, MONGOCRYPT_GENERIC_ERROR_CODE }
// libmongocrypt: mongocrypt_ctx_setopt_key_material
"keyMaterial should have length 96, but has length 84",

// { MONGOCRYPT_STATUS_ERROR_CLIENT, MONGOCRYPT_GENERIC_ERROR_CODE }
// libmongocrypt: _mongocrypt_parse_optional_utf8, _mongocrypt_parse_required_utf8
"expected UTF-8 key",

// { MONGOCRYPT_STATUS_ERROR_CLIENT, MONGOCRYPT_GENERIC_ERROR_CODE }
// libmongocrypt: _mongocrypt_check_allowed_fields
"Unexpected field: 'invalid'",

// { MONGOCRYPT_STATUS_ERROR_CLIENT, MONGOCRYPT_GENERIC_ERROR_CODE }
// libmongocrypt: _kms_done
"key material not expected length",
};

const bsoncxx::stdx::string_view message = exception.what();

const auto iter = std::find_if(std::begin(patterns),
std::end(patterns),
[message](bsoncxx::stdx::string_view pattern) {
return message.find(pattern) != message.npos;
});

if (iter != std::end(patterns)) {
// Treat this as a client-side error.
const auto pattern = *iter;
CAPTURE(pattern);
REQUIRE(is_client_error.get_bool().value);
} else {
// Treat this as a server-side error.
REQUIRE(!is_client_error.get_bool().value);
}
}

Expand Down