Skip to content

Commit a2755c3

Browse files
committed
fix(cmake): cap find_package(httplib) at < 0.20 and flag the multipart pin
The medkit_find_cpp_httplib pkg-config tier already masks cpp-httplib >= 0.20 (which dropped the multipart Request::has_file API the gateway uses), but the find_package(httplib) fallback accepted any version. A distro shipping httplibConfig.cmake for 0.26 would resolve there and skip the vendored fallback. Apply the same < 0.20 cap to that tier; unversioned source-build configs still pass through. Add FIXME(#409) markers at the multipart sites (route_registry, response_types, bulkdata_handlers, script_handlers) that depend on the removed httplib::MultipartFormData / req.files API, and link #409 from the cmake pin so the vendored-header workaround stays tracked.
1 parent 9e87d73 commit a2755c3

5 files changed

Lines changed: 21 additions & 3 deletions

File tree

src/ros2_medkit_cmake/cmake/ROS2MedkitCompat.cmake

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ endmacro()
8585
# On Lyrical/Resolute the system package is 0.26.x which removed the
8686
# multipart `Request::has_file` / `get_file_value` API used by
8787
# BulkDataHandlers, so we cap pkg-config at < 0.20 and fall back to the
88-
# vendored copy until the handler is migrated to the newer API.
88+
# vendored copy until the handler is migrated to the newer API (see #409).
8989
#
9090
# Creates a unified alias target `cpp_httplib_target` for consumers.
9191
# ---------------------------------------------------------------------------
@@ -107,9 +107,17 @@ macro(medkit_find_cpp_httplib)
107107
message(STATUS "[MedkitCompat] cpp-httplib: using pkg-config (${cpp_httplib_VERSION})")
108108
else()
109109
find_package(httplib QUIET)
110-
if(TARGET httplib::httplib)
110+
# Cap this tier at [0.14, 0.20) like the pkg-config tier above: a future
111+
# distro shipping httplibConfig.cmake for 0.26 would otherwise resolve here
112+
# and skip the vendored fallback, even though 0.26 dropped the multipart
113+
# Request::has_file API. An unversioned config (deliberate source build) is
114+
# trusted and passes through.
115+
if(TARGET httplib::httplib AND DEFINED httplib_VERSION AND NOT httplib_VERSION VERSION_LESS "0.20")
116+
message(STATUS "[MedkitCompat] cpp-httplib: cmake config ${httplib_VERSION} removes the multipart Request::has_file API; falling back to vendored 0.14")
117+
endif()
118+
if(TARGET httplib::httplib AND (NOT DEFINED httplib_VERSION OR httplib_VERSION VERSION_LESS "0.20"))
111119
add_library(cpp_httplib_target ALIAS httplib::httplib)
112-
message(STATUS "[MedkitCompat] cpp-httplib: using cmake config (source build)")
120+
message(STATUS "[MedkitCompat] cpp-httplib: using cmake config (source build, version '${httplib_VERSION}')")
113121
elseif(_mfch_VENDORED_DIR AND EXISTS "${_mfch_VENDORED_DIR}/httplib.h")
114122
add_library(cpp_httplib_vendored INTERFACE)
115123
target_include_directories(cpp_httplib_vendored SYSTEM INTERFACE "${_mfch_VENDORED_DIR}")

src/ros2_medkit_gateway/include/ros2_medkit_gateway/http/response_types.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ struct BinaryResponse {
5656
struct MultipartBody {
5757
/// Raw parts as parsed by cpp-httplib. Each part carries name, filename,
5858
/// content type, and the part bytes.
59+
// FIXME(#409): httplib::MultipartFormDataItems is unavailable in cpp-httplib
60+
// >= 0.20 (req.form API). Replace with a gateway-owned part type to decouple
61+
// handlers from the cpp-httplib struct and lift the vendored-header pin.
5962
httplib::MultipartFormDataItems parts;
6063
};
6164

src/ros2_medkit_gateway/src/http/handlers/bulkdata_handlers.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,8 @@ BulkDataHandlers::upload(const http::TypedRequest & req, const http::MultipartBo
478478
// every named part into MultipartBody.parts; walk the vector instead of
479479
// relying on `req.files` map ordering so the typed surface does not leak
480480
// through to the cpp-httplib shape.
481+
// FIXME(#409): httplib::MultipartFormData is unavailable in cpp-httplib
482+
// >= 0.20; migrate to the req.form API (tracked with the vendored-header pin).
481483
const httplib::MultipartFormData * file_part = nullptr;
482484
const httplib::MultipartFormData * description_part = nullptr;
483485
const httplib::MultipartFormData * metadata_part = nullptr;

src/ros2_medkit_gateway/src/http/handlers/script_handlers.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ ScriptHandlers::upload_script(const http::TypedRequest & req, const http::Multip
210210
// MultipartBody.parts; we walk the vector instead of relying on `req.files`
211211
// map ordering so the typed surface does not leak through to the cpp-httplib
212212
// shape.
213+
// FIXME(#409): httplib::MultipartFormData is unavailable in cpp-httplib
214+
// >= 0.20; migrate to the req.form API (tracked with the vendored-header pin).
213215
const httplib::MultipartFormData * file_part = nullptr;
214216
const httplib::MultipartFormData * metadata_part = nullptr;
215217
for (const auto & part : body.parts) {

src/ros2_medkit_gateway/src/openapi/route_registry.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,9 @@ RouteEntry & RouteRegistry::multipart_upload(
999999
// body.parts default-constructs empty; the loop below populates it from req.files.
10001000
// cpp-httplib exposes parsed multipart entries via `req.files`; surface
10011001
// them through MultipartBody.parts as MultipartFormData entries.
1002+
// FIXME(#409): `req.files` / httplib::MultipartFormData are unavailable in
1003+
// cpp-httplib >= 0.20; migrate to the req.form API so the system package can
1004+
// be used on Lyrical/Resolute instead of the vendored 0.14.3 header.
10021005
for (const auto & [name, file] : req.files) {
10031006
httplib::MultipartFormData mp;
10041007
mp.name = name;

0 commit comments

Comments
 (0)