Skip to content

CXX-3302 Update bsoncxx validation examples (CDRIVER-5710, CDRIVER-6017) #1416

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 6 commits into from
Jun 12, 2025
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 @@ -14,7 +14,7 @@
# Only MONGOC_DOWNLOAD_VERSION needs to be updated when pinning to an unreleased commit.
# 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 = '2.0.0'
MONGOC_VERSION_MINIMUM = '2.0.2'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also raise the minimum required C Driver version for downstream users if that is preferable (CXX-3302), but I do not think it is necessary at this time.

I am open to debate, but I slightly prefer bumping the minimum required version to 2.0.2.

I see three distinct versions:

  1. MONGOC_VERSION_MINIMUM is the tested version in CI.
  2. MONGOC_DOWNLOAD_VERSION is the automatically downloaded version.
  3. MONGOC_REQUIRED_VERSION is the required version.

I expect these do not strictly need to match, as is proposed in this PR. However, only bumping tested+downloaded means tests fail with the minimum required C driver. That may be unlikely to impact users, but bumping all to 2.0.2 avoids the possibility. The other benefit: upgrading to C++ driver 4.1.0 (with minimum C driver 2.0.2) is guaranteed to have the bug fix of CDRIVER-6017.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Included a reference to CXX-3302 for tracking purposes.



class InstallCDriver(Function):
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/config_generator/components/mongohouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from config_generator.etc.utils import bash_exec

from shrub.v3.evg_build_variant import BuildVariant
from shrub.v3.evg_command import EvgCommandType
from shrub.v3.evg_command import EvgCommandType, ec2_assume_role
from shrub.v3.evg_task import EvgTask, EvgTaskRef


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 @@ -443,7 +443,7 @@ functions:
type: setup
params:
updates:
- { key: mongoc_version_minimum, value: 2.0.0 }
- { key: mongoc_version_minimum, value: 2.0.2 }
- 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 @@ -16,6 +16,7 @@ Changes prior to 3.9.0 are documented as [release notes on GitHub](https://githu
### Changed

- CMake 3.16.0 or newer is required when `ENABLE_TESTS=ON` for compatibility with the updated Catch2 library version (3.7.0 -> 3.8.1).
- Bump the minimum required C Driver version to [2.0.2](https://github.com/mongodb/mongo-c-driver/releases/tag/2.0.2).

## 4.1.0

Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ else()
endif()

# Also update etc/purls.txt.
set(BSON_REQUIRED_VERSION 2.0.0)
set(MONGOC_REQUIRED_VERSION 2.0.0)
set(MONGOC_DOWNLOAD_VERSION 2.0.0)
set(BSON_REQUIRED_VERSION 2.0.2)
set(MONGOC_REQUIRED_VERSION 2.0.2)
set(MONGOC_DOWNLOAD_VERSION 2.0.2)

# All of our target compilers support the deprecated
# attribute. Normally, we would just let the GenerateExportHeader
Expand Down
14 changes: 7 additions & 7 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/[email protected].0",
"bom-ref": "pkg:github/mongodb/[email protected].2",
"copyright": "Copyright 2009-present MongoDB, Inc.",
"externalReferences": [
{
"type": "distribution",
"url": "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/v2.0.0.tar.gz"
"url": "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/v2.0.2.tar.gz"
},
{
"type": "website",
"url": "https://github.com/mongodb/mongo-c-driver/tree/v2.0.0"
"url": "https://github.com/mongodb/mongo-c-driver/tree/v2.0.2"
}
],
"group": "mongodb",
Expand All @@ -22,18 +22,18 @@
}
],
"name": "mongo-c-driver",
"purl": "pkg:github/mongodb/[email protected].0",
"purl": "pkg:github/mongodb/[email protected].2",
"type": "library",
"version": "v2.0.0"
"version": "v2.0.2"
}
],
"dependencies": [
{
"ref": "pkg:github/mongodb/[email protected].0"
"ref": "pkg:github/mongodb/[email protected].2"
}
],
"metadata": {
"timestamp": "2025-04-02T19:47:45.682404+00:00",
"timestamp": "2025-06-12T17:36:20.890153+00:00",
"tools": [
{
"externalReferences": [
Expand Down
14 changes: 7 additions & 7 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/[email protected].0",
"bom-ref": "pkg:github/mongodb/[email protected].2",
"copyright": "Copyright 2009-present MongoDB, Inc.",
"externalReferences": [
{
"type": "distribution",
"url": "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/v2.0.0.tar.gz"
"url": "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/v2.0.2.tar.gz"
},
{
"type": "website",
"url": "https://github.com/mongodb/mongo-c-driver/tree/v2.0.0"
"url": "https://github.com/mongodb/mongo-c-driver/tree/v2.0.2"
}
],
"group": "mongodb",
Expand All @@ -22,18 +22,18 @@
}
],
"name": "mongo-c-driver",
"purl": "pkg:github/mongodb/[email protected].0",
"purl": "pkg:github/mongodb/[email protected].2",
"type": "library",
"version": "v2.0.0"
"version": "v2.0.2"
}
],
"dependencies": [
{
"ref": "pkg:github/mongodb/[email protected].0"
"ref": "pkg:github/mongodb/[email protected].2"
}
],
"metadata": {
"timestamp": "2025-05-01T20:23:28.401764+00:00",
"timestamp": "2025-06-12T17:36:20.890153+00:00",
"tools": [
{
"externalReferences": [
Expand Down
2 changes: 1 addition & 1 deletion etc/make_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
show_default=True,
help='The remote reference which points to the mongodb/mongo-cxx-driver repo')
@click.option('--c-driver-build-ref',
default='2.0.0',
default='2.0.2',
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!

# bson and mongoc may be obtained via cmake/FetchMongoC.cmake.
pkg:github/mongodb/[email protected].0
pkg:github/mongodb/[email protected].2
4 changes: 2 additions & 2 deletions examples/api/bsoncxx/examples/validation/basic_usage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ void example() {

EXPECT(bsoncxx::validate(data, length) == bsoncxx::validate(data, length, options, &offset));

// Not set when valid.
EXPECT(offset == 123u);
// Set to 0 when valid.
EXPECT(offset == 0u);
}
}
// [Example]
Expand Down
4 changes: 2 additions & 2 deletions examples/api/bsoncxx/examples/validation/validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ void example(std::uint8_t const* bytes, std::size_t length) {

EXPECT(!bsoncxx::validate(bytes, length, options, &offset));

// Offset of `"$numberInt": "123"` relative to start of the sub-document. (CDRIVER-5710)
EXPECT(offset == 4u);
// Offset of `"$numberInt": "123"` relative to start of the document.
EXPECT(offset == 31u);
}
}
// [Example]
Expand Down