Skip to content
Open
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
4ef9e38
[aws][system] Add C++ dependencies images
mcopik May 3, 2022
2dc3894
[aws][system] Add C++ dependencies images
mcopik May 3, 2022
3dd45ef
[aws] Change name style of C++ Docker images
mcopik May 7, 2022
72b88ad
[aws] Add AWS C++ Lambda runtime as dependency
mcopik May 7, 2022
1cdcc74
[aws] Add the basic wrapper for C++
mcopik May 7, 2022
17c69fe
[aws] Add Docker build container for C++
mcopik May 7, 2022
53f81f7
[benchmarks] Add sleep benchmark implementation for C++
mcopik May 7, 2022
67560c8
[aws] Define necessary package files for C++
mcopik May 7, 2022
a9b5218
[system] Add Docker build arguments for C++ images
mcopik May 7, 2022
3c3700c
[aws] Implement correct return from C++
mcopik May 7, 2022
61bbffa
[aws] [system] First version of support for C++ benchmarks
mcopik May 7, 2022
89d29e7
[aws] Add Boost UUID in handler
mcopik May 7, 2022
5db9fc2
[aws] Support HTTP trigger for C++
mcopik May 7, 2022
c6a1a81
[aws] Minor update of C++ dependencies
mcopik May 7, 2022
dc3df69
[aws] Add key-value wrapper for C++ benchmarks
mcopik May 15, 2022
eb5d0b6
[benchmarks] Linting
mcopik May 15, 2022
2f035fc
[system] Add logging of C++ build steps
mcopik May 15, 2022
1c5d85c
[aws] Add Redis wrappers for C++
mcopik May 15, 2022
9a96d72
[aws] Move Dockerfiles to a new directory
mcopik Jun 18, 2025
b5fbb12
[dev] Linting
mcopik Jun 18, 2025
a8239a1
[aws] Rename C++ utility function and apply formatting
mcopik Jun 19, 2025
8e1f93a
[aws] Pin hiredis version
mcopik Jun 19, 2025
b7ab8e4
[aws] Fix merge error
mcopik Jun 19, 2025
068adfd
[aws] Fix various bugs for C++ benchmarks, as pointed out during review
mcopik Jun 19, 2025
ef25201
[aws] Fix generation of cloud runtime
mcopik Jun 20, 2025
3fa330f
[aws] Add architecture configuration for cpp base images. Ensure the …
HoriaMercan Jun 25, 2025
1ff7b98
Implemented 210-thumbnail benchmark in cpp.
HoriaMercan Jun 29, 2025
faf4ffd
[aws] Added docker dependencies for opencv
HoriaMercan Jun 29, 2025
bd9a88a
Delete Base64.hpp file
HoriaMercan Jul 2, 2025
85ff323
Optimize storage.cpp by using boost's bufferstream
HoriaMercan Jul 2, 2025
6ae77be
Added cpp support for graph pagerank
HoriaMercan Jul 7, 2025
6114498
Added C++ in config for Pagerank Benchmark
HoriaMercan Jul 8, 2025
330d543
Added cpp_dependencies config for building CMakeList.txt for thumbnai…
HoriaMercan Jul 8, 2025
53c3c07
Added graph-bfs benchmark in C++ AWS
HoriaMercan Jul 8, 2025
3f55a9d
Added Torch & TorchVIsion dependencies to C++. Added image-recognitio…
HoriaMercan Jul 10, 2025
5a1557d
[lint] Remove dead code
HoriaMercan Oct 13, 2025
b38c604
Merge branch 'master' into cpp_benchmarks
mcopik Oct 27, 2025
9fb0dd3
[dev] Linting
mcopik Oct 27, 2025
bab4ce2
[aws] Fix Boost URL
mcopik Dec 6, 2025
0b25d4b
[system] Fix incorrect logging
mcopik Dec 6, 2025
07b6a8e
Merge branch 'cpp_benchmarks' of github.com:spcl/serverless-benchmark…
mcopik Dec 6, 2025
bf46204
[aws] Add container template for C++ functions
mcopik Dec 6, 2025
6c027de
[AWS-cpp] Fix boost download link
DJAntivenom Nov 28, 2025
c6d5e0e
[types] Fix __str__ method of Language enum
DJAntivenom Nov 28, 2025
a9c35cb
[aws] [system] Separate handling of containers and code packages
mcopik Dec 6, 2025
bba1995
Merge branch 'cpp_benchmarks' of github.com:spcl/serverless-benchmark…
mcopik Dec 6, 2025
27e053d
[aws] Add dynamic resolution of necessary dependencies for C++ contai…
mcopik Dec 7, 2025
38bdbe2
[system] Support storage configuration in regression
mcopik Dec 7, 2025
468cd35
[system] Add examples of configurations for different languages
mcopik Dec 7, 2025
5558f32
[openwhisk] Adapt the OpenWhisk implementation to new container build…
mcopik Dec 7, 2025
3fb59b2
[system] Extend regression with the sleep microbenchmark
mcopik Dec 7, 2025
2c206a6
[docs] Update documentation on storage IP replacement
mcopik Dec 7, 2025
5a893a8
[system] Linting and typing fixes
mcopik Dec 7, 2025
5ee60d5
[system] Bump Python requirements
mcopik Dec 7, 2025
2b1aa03
[system] Update CI config
mcopik Dec 7, 2025
b2fe903
[docs] Update list of benchmarks
mcopik Dec 7, 2025
5ba7dee
[docs] Update documentation on Docker containers
mcopik Dec 7, 2025
a1464e7
Revise build documentation for clarity and detail
mcopik Dec 7, 2025
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
6 changes: 4 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
version: 2.1

orbs:
python: circleci/python@1.4.0
python: circleci/python@2.1
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

circleci python orb 2.1 breaking changes compared to 1.4.0

💡 Result:

Short summary of likely breaking changes when moving circleci/python from 1.4.0 → 2.1

  • Major-version semantics: 2.x is a breaking release — expect incompatible changes to commands/parameters/executors. [1]
  • Default images / Python versions bumped (newer cimg images); some orb steps now run on images that enforce PEP 668 (can break orb commands that try to pip-install into system-managed envs). Update any steps that assume older Python image behavior. [2]
  • Migration from Python wrapper-scripts to shell-based implementations for some orbs/commands (done to avoid PEP 668 issues) — this can change how environment/exit codes/outputs behave and may rename parameters. [2]
  • Executors, command names or parameters may have been renamed or removed (minor/patch should be compatible, but major bumps may remove elements present in 1.4.0). Test and verify usages in your config. [1][3]

Action items

  • Inspect the circleci/python orb page and its changelog/versions in the Orb Registry for exact diffs and element-level changes. [3]
  • Run circleci orb source circleci/[email protected] and circleci/[email protected] (or view the registry source) and diff commands/jobs/executors used by your config.
  • Test in a branch and pin the orb to an exact semver (e.g. circleci/[email protected]) before rolling out.

Sources

  • Orb SemVer / breaking-change guidance. [1]
  • “externally-managed-environment” / PEP 668 note and migration to shell scripts. [2]
  • circleci/python orb registry page (versions & docs). [3]

🏁 Script executed:

# Check the full CircleCI config to understand Python version usage and executor configuration
cat -n .circleci/config.yml | head -100

Repository: spcl/serverless-benchmarks

Length of output: 3258


🏁 Script executed:

# Check if there are any CI logs or test results that show the orb 2.1 is working
git log --oneline --all -20 | head -20

Repository: spcl/serverless-benchmarks

Length of output: 977


🌐 Web query:

circleci python orb 2.1 default Python version executor

💡 Result:

The python/default executor in the circleci/python 2.x orb defaults to Python 3.8 (the executor has a parameter tag with default "3.8"). You can override it by declaring the executor with a tag, e.g.:

executor:
name: python/default
tag: "3.11"

[1][2]

Sources

  • CircleCI Discuss showing executor definition (default tag '3.8'). [1]
  • CircleCI docs / Python orb usage (shows using python/default executor and overriding via tag). [2]

Add explicit Python version to test-aws executor to match linting job.

The Python orb 2.1 introduces breaking changes from 1.4.0, including a bump to newer default images with PEP 668 enforcement. The linting job correctly specifies Python 3.10 explicitly, but the test-aws job uses python/default without a tag parameter (line 42), which defaults to Python 3.8 in orb 2.1. Add an explicit tag: '3.10' to the test-aws executor to ensure consistency and avoid unexpected behavior from implicit version differences.

🤖 Prompt for AI Agents
In .circleci/config.yml around lines 4 to 4 (and the test-aws executor usage
near line 42), the test-aws job relies on the orb's default Python image which
in python orb v2.1 defaults to 3.8 and can cause mismatches with the linting
job; update the test-aws executor declaration to explicitly set the python tag
to '3.10' (e.g., add tag: '3.10' under the python executor) so both jobs use the
same Python 3.10 image and avoid PEP 668/behavior differences from the orb
default.


jobs:
linting:
executor: python/default
executor:
name: 'python/default'
tag: '3.10'
steps:
- checkout
- restore_cache:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ You can cite our software repository as well, using the citation button on the r

Requirements:
- Docker (at least 19)
- Python 3.7+ with:
- Python 3.10+ with:
- pip
- venv
- `libcurl` and its headers must be available on your system to install `pycurl`
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/000.microbenchmarks/010.sleep/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"timeout": 120,
"memory": 128,
"languages": ["python", "nodejs"],
"languages": ["python", "nodejs", "cpp"],
"modules": []
}
22 changes: 22 additions & 0 deletions benchmarks/000.microbenchmarks/010.sleep/cpp/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

#include <aws/core/Aws.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/lambda-runtime/runtime.h>

#include <thread>
#include <iostream>

Aws::Utils::Json::JsonValue function(Aws::Utils::Json::JsonView json)
{
int sleep = json.GetInteger("sleep");

std::chrono::seconds timespan(sleep);
std::this_thread::sleep_for(timespan);

//std::string res_json = "{ \"result\": " + std::to_string(sleep) + "}";
//return aws::lambda_runtime::invocation_response::success(res_json, "application/json");
Aws::Utils::Json::JsonValue val;
val.WithObject("result", std::to_string(sleep));
return val;
}

5 changes: 3 additions & 2 deletions benchmarks/200.multimedia/210.thumbnailer/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"timeout": 60,
"memory": 256,
"languages": ["python", "nodejs"],
"modules": ["storage"]
"languages": ["python", "nodejs", "cpp"],
"modules": ["storage"],
"cpp_dependencies": ["opencv", "boost"]
}
27 changes: 27 additions & 0 deletions benchmarks/200.multimedia/210.thumbnailer/cpp/function.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

#include <opencv2/opencv.hpp>
#include <opencv2/imgcodecs.hpp>

void thumbnailer(cv::Mat &in, int64_t width, int64_t height, cv::Mat &out)
{
try
{
// Calculate thumbnail size while maintaining aspect ratio
int orig_width = in.cols;
int orig_height = in.rows;

double scale_w = static_cast<double>(width) / orig_width;
double scale_h = static_cast<double>(height) / orig_height;
double scale = std::min(scale_w, scale_h); // Use smaller scale to fit within bounds

int new_width = static_cast<int>(orig_width * scale);
int new_height = static_cast<int>(orig_height * scale);

// Resize image (equivalent to PIL's thumbnail method)
cv::resize(in, out, cv::Size(new_width, new_height), cv::INTER_LINEAR);
}
catch (const cv::Exception &e)
{
std::cerr << "OpenCV error: " << e.what() << std::endl;
}
}
Comment on lines +7 to +27
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Rethrow exceptions to avoid swallowing errors.

The catch block logs the error but doesn't rethrow, leaving the out parameter in an undefined state. The caller has no way to detect that the operation failed, which could lead to silent failures downstream.

Apply this diff to rethrow the exception:

   catch (const cv::Exception &e)
   {
     std::cerr << "OpenCV error: " << e.what() << std::endl;
+    throw;
   }
🤖 Prompt for AI Agents
In benchmarks/200.multimedia/210.thumbnailer/cpp/function.hpp around lines 7 to
27, the catch block logs OpenCV errors but swallows the exception leaving `out`
undefined and the caller unaware of failure; after logging the error, rethrow
the exception (use `throw;` to preserve the original exception) so the failure
propagates to the caller and they can handle it appropriately.

117 changes: 117 additions & 0 deletions benchmarks/200.multimedia/210.thumbnailer/cpp/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@

#include <aws/core/Aws.h>
#include <aws/core/utils/json/JsonSerializer.h>

#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_io.hpp>

#include <iostream>
#include <vector>

#include "function.hpp"
#include "storage.hpp"
#include "utils.hpp"

Aws::Utils::Json::JsonValue function(Aws::Utils::Json::JsonView request)
{
sebs::Storage client_ = sebs::Storage::get_client();

auto bucket_obj = request.GetObject("bucket");
if (!bucket_obj.IsObject())
{
Aws::Utils::Json::JsonValue error;
error.WithString("error", "Bucket object is not valid.");
return error;
}
auto bucket_name = bucket_obj.GetString("bucket");
auto input_key_prefix = bucket_obj.GetString("input");
auto output_key_prefix = bucket_obj.GetString("output");

auto image_name = request.GetObject("object").GetString("key");
auto width = request.GetObject("object").GetInteger("width");
auto height = request.GetObject("object").GetInteger("height");

Comment on lines +31 to +34
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Validate presence and types of object.key/width/height.

Avoid crashes when fields are missing or wrong types.

Apply this diff:

-  auto image_name = request.GetObject("object").GetString("key");
-  auto width = request.GetObject("object").GetInteger("width");
-  auto height = request.GetObject("object").GetInteger("height");
+  if (!request.ValueExists("object") ||
+      !request.GetObject("object").ValueExists("key") ||
+      !request.GetObject("object").ValueExists("width") ||
+      !request.GetObject("object").ValueExists("height")) {
+    Aws::Utils::Json::JsonValue error;
+    error.WithString("error", "Missing object.key/width/height.");
+    return error;
+  }
+  auto image_name = request.GetObject("object").GetString("key");
+  auto width = request.GetObject("object").GetInteger("width");
+  auto height = request.GetObject("object").GetInteger("height");
+  if (width <= 0 || height <= 0) {
+    Aws::Utils::Json::JsonValue error;
+    error.WithString("error", "Width/height must be positive.");
+    return error;
+  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
auto image_name = request.GetObject("object").GetString("key");
auto width = request.GetObject("object").GetInteger("width");
auto height = request.GetObject("object").GetInteger("height");
if (!request.ValueExists("object") ||
!request.GetObject("object").ValueExists("key") ||
!request.GetObject("object").ValueExists("width") ||
!request.GetObject("object").ValueExists("height")) {
Aws::Utils::Json::JsonValue error;
error.WithString("error", "Missing object.key/width/height.");
return error;
}
auto image_name = request.GetObject("object").GetString("key");
auto width = request.GetObject("object").GetInteger("width");
auto height = request.GetObject("object").GetInteger("height");
if (width <= 0 || height <= 0) {
Aws::Utils::Json::JsonValue error;
error.WithString("error", "Width/height must be positive.");
return error;
}
🤖 Prompt for AI Agents
In benchmarks/200.multimedia/210.thumbnailer/cpp/main.cpp around lines 31 to 34,
the code assumes request.GetObject("object") always contains "key", "width", and
"height" with correct types; add defensive checks to validate existence and
types before using them: verify the top-level "object" exists and is an object,
check that "key" exists and is a string, and that "width" and "height" exist and
are integers (or convertible), and if any check fails return or throw a
descriptive error (or set an error response) instead of proceeding; use the
appropriate API (HasMember/isString/isInt or equivalent) to test types and
extract values safely.

std::string body_str;
uint64_t download_time;
{
std::string input_key = input_key_prefix + "/" + image_name;
auto ans = client_.download_file(bucket_name, input_key);
body_str = std::get<0>(ans);
download_time = std::get<1>(ans);

if (body_str.empty())
{
Aws::Utils::Json::JsonValue error;
error.WithString("error", "Failed to download object from S3: " + input_key);
return error;
}
}

std::vector<char> vectordata(body_str.begin(), body_str.end());
cv::Mat image = imdecode(cv::Mat(vectordata), 1);

// Apply the thumbnailer function and measure the computing time
cv::Mat image2;
uint64_t computing_time;
{
auto start_time = timeSinceEpochMicrosec();
thumbnailer(image, width, height, image2);
computing_time = timeSinceEpochMicrosec() - start_time;
}

std::vector<unsigned char> out_buffer;
cv::imencode(".jpg", image2, out_buffer);

// Create a unique key name for the output image
std::string key_name;
{
std::string output_key = output_key_prefix + "/" + image_name;
std::string name, extension;
if (output_key.find_last_of('.') != std::string::npos)
{
name = output_key.substr(0, output_key.find_last_of('.'));
extension = output_key.substr(output_key.find_last_of('.'));
}
else
{
name = output_key;
extension = "";
}
key_name = name + "."
+ boost::uuids::to_string(boost::uuids::random_generator()())
+ extension;
}

// Upload the resulting image to S3
// If the upload fails, return an error
Aws::String upload_data(out_buffer.begin(), out_buffer.end());

uint64_t upload_time = client_.upload_random_file(
bucket_name, key_name, true,
reinterpret_cast<char *>(out_buffer.data()), out_buffer.size());

if (upload_time == 0)
{
Aws::Utils::Json::JsonValue error;
error.WithString("error", "Failed to upload object to S3: " + key_name);
return error;
}


Aws::Utils::Json::JsonValue val;
Aws::Utils::Json::JsonValue result;
Aws::Utils::Json::JsonValue measurements;

result.WithString("bucket", bucket_name);
result.WithString("key", key_name);
val.WithObject("result", result);

measurements.WithInteger("download_time", download_time);
measurements.WithInteger("upload_time", upload_time);
measurements.WithInteger("compute_time", computing_time);
measurements.WithInteger("download_size", vectordata.size());
measurements.WithInteger("upload_size", out_buffer.size());
val.WithObject("measurements", measurements);
return val;
}
5 changes: 3 additions & 2 deletions benchmarks/400.inference/411.image-recognition/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"timeout": 60,
"memory": 512,
"languages": ["python"],
"modules": ["storage"]
"languages": ["python", "cpp"],
"modules": ["storage"],
"cpp_dependencies": ["torch", "opencv"]
}
116 changes: 116 additions & 0 deletions benchmarks/400.inference/411.image-recognition/cpp/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#include <aws/core/Aws.h>
#include <aws/core/utils/json/JsonSerializer.h>

#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_io.hpp>

#include <iostream>
#include <vector>

#include "utils.hpp"
#include "storage.hpp"

#include <torch/torch.h>
#include <torch/script.h>

#include <torchvision/vision.h>
#include <torchvision/models/resnet.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/opencv.hpp>


#define kIMAGE_SIZE 224
#define kCHANNELS 3
#define kTOP_K 3


bool load_image(cv::Mat &image)
{

if (image.empty() || !image.data)
{
return false;
}
cv::cvtColor(image, image, cv::COLOR_BGR2RGB);

int w = image.size().width, h = image.size().height;
cv::Size scale((int)256 * ((float)w) / h, 256);
cv::resize(image, image, scale);
w = image.size().width, h = image.size().height;
image = image(cv::Range(16, 240), cv::Range(80, 304));
image.convertTo(image, CV_32FC3, 1.0f / 255.0f);

Comment on lines +37 to +43
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Unsafe fixed ROI crop; center-crop robustly after resizing the shorter side.

Current indices can go out of bounds (e.g., width 256). Replace with size-aware crop.

-    int w = image.size().width, h = image.size().height;
-    cv::Size scale((int)256 * ((float)w) / h, 256);
-    cv::resize(image, image, scale);
-    w = image.size().width, h = image.size().height;
-    image = image(cv::Range(16, 240), cv::Range(80, 304));
-    image.convertTo(image, CV_32FC3, 1.0f / 255.0f);
+    int w = image.cols, h = image.rows;
+    int short_side = std::min(w, h);
+    cv::Size scaled(
+        static_cast<int>(std::round(w * 256.0 / short_side)),
+        static_cast<int>(std::round(h * 256.0 / short_side)));
+    cv::resize(image, image, scaled);
+    w = image.cols; h = image.rows;
+    int x = std::max(0, std::min((w - kIMAGE_SIZE) / 2, w - kIMAGE_SIZE));
+    int y = std::max(0, std::min((h - kIMAGE_SIZE) / 2, h - kIMAGE_SIZE));
+    image = image(cv::Rect(x, y, kIMAGE_SIZE, kIMAGE_SIZE));
+    image.convertTo(image, CV_32FC3, 1.0f / 255.0f);

Committable suggestion skipped: line range outside the PR's diff.

return true;
}

int recognition(cv::Mat &image)
{

static bool initialized = false;
static torch::jit::script::Module module;
if (!initialized)
{
try
{
std::cout << "Initialize ResNet50 model" << std::endl;
module = torch::jit::load("./resnet50.pt");
}
catch (const c10::Error &e)
{
std::cerr << "error loading the model\n";
return -1;
}
initialized = true;
}

if (load_image(image))
{

auto input_tensor = torch::from_blob(
image.data, {1, kIMAGE_SIZE, kIMAGE_SIZE, kCHANNELS});
input_tensor = input_tensor.permute({0, 3, 1, 2});

input_tensor[0][0] = input_tensor[0][0].sub_(0.485).div_(0.229);
input_tensor[0][1] = input_tensor[0][1].sub_(0.456).div_(0.224);
input_tensor[0][2] = input_tensor[0][2].sub_(0.406).div_(0.225);

torch::Tensor out_tensor = module.forward({input_tensor}).toTensor();
auto results = out_tensor.sort(-1, true);
auto softmaxs = std::get<0>(results)[0].softmax(0);
auto indexs = std::get<1>(results)[0];

std::cout << indexs[0].item<int>() << " " << softmaxs[0].item<double>() << std::endl;
return indexs[0].item<int>();


}

return -1;
}

Aws::Utils::Json::JsonValue function(Aws::Utils::Json::JsonView request)
{
sebs::Storage client_ = sebs::Storage::get_client();

auto bucket_obj = request.GetObject("bucket");
if (!bucket_obj.IsObject())
{
Aws::Utils::Json::JsonValue error;
error.WithString("error", "Bucket object is not valid.");
return error;
}

auto bucket_name = bucket_obj.GetString("bucket");
auto input_prefix = bucket_obj.GetString("input");
auto model_prefix = bucket_obj.GetString("model");
auto key = request.GetObject("object").GetString("input");
auto model_key = request.GetObject("object").GetString("model");

Comment on lines +96 to +109
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Validate request schema before GetString() calls.

Guard against missing keys to prevent exceptions.

-    auto bucket_obj = request.GetObject("bucket");
-    if (!bucket_obj.IsObject())
+    if (!request.ValueExists("bucket") || !request.GetObject("bucket").IsObject())
     {
         Aws::Utils::Json::JsonValue error;
         error.WithString("error", "Bucket object is not valid.");
         return error;
     }
-
-    auto bucket_name = bucket_obj.GetString("bucket");
-    auto input_prefix = bucket_obj.GetString("input");
-    auto model_prefix = bucket_obj.GetString("model");
-    auto key = request.GetObject("object").GetString("input");
-    auto model_key = request.GetObject("object").GetString("model");
+    auto bucket_obj = request.GetObject("bucket");
+    if (!bucket_obj.ValueExists("bucket") || !bucket_obj.ValueExists("input") || !bucket_obj.ValueExists("model")
+        || !request.ValueExists("object")
+        || !request.GetObject("object").ValueExists("input")
+        || !request.GetObject("object").ValueExists("model")) {
+        Aws::Utils::Json::JsonValue error;
+        error.WithString("error", "Missing required keys: bucket.bucket/input/model and object.input/model.");
+        return error;
+    }
+    auto bucket_name = bucket_obj.GetString("bucket");
+    auto input_prefix = bucket_obj.GetString("input");
+    auto model_prefix = bucket_obj.GetString("model");
+    auto key = request.GetObject("object").GetString("input");
+    auto model_key = request.GetObject("object").GetString("model");
🤖 Prompt for AI Agents
In benchmarks/400.inference/411.image-recognition/cpp/main.cpp around lines 96
to 109, the code calls GetString() on JSON members without checking they exist
or are strings; add guards that verify bucket_obj has the keys "bucket",
"input", and "model" and that request.GetObject("object") has "input" and
"model", and confirm each member IsString()/HasMember() (or equivalent) before
calling GetString(); if any check fails, build and return an
Aws::Utils::Json::JsonValue error with a clear message indicating which key is
missing or of the wrong type.


Aws::Utils::Json::JsonValue val;
Aws::Utils::Json::JsonValue result;
Aws::Utils::Json::JsonValue measurements;

return val;
}
5 changes: 3 additions & 2 deletions benchmarks/500.scientific/501.graph-pagerank/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"timeout": 120,
"memory": 512,
"languages": ["python"],
"modules": []
"languages": ["python", "cpp"],
"modules": [],
"cpp_dependencies": ["igraph"]
}
Loading