Skip to content

Replace boost::format with libfmt#7363

Merged
DennisOSRM merged 17 commits intomasterfrom
copilot/replace-boost-format-with-libfmt
Feb 21, 2026
Merged

Replace boost::format with libfmt#7363
DennisOSRM merged 17 commits intomasterfrom
copilot/replace-boost-format-with-libfmt

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 18, 2026

Replace boost::format with libfmt across the code base

Summary

Complete: Successfully replaced all boost::format usage with libfmt across the codebase

Plan

  • Explore repository and understand boost::format usage (12 instances across 8 files)
  • Verify libfmt is already available in the project (confirmed in third_party/fmt/)
  • Understand usage patterns and create replacement strategy
  • Replace boost::format with fmt::format in all files
  • Address code review feedback (removed unnecessary include)
  • Verify syntax compiles correctly
  • Run code review (completed with no actionable items for this PR)
  • Run security checks (CodeQL - no issues found)
  • Verify no remaining boost::format references
  • Fix code formatting as reported by CI
  • Fix npm audit security vulnerability in tar package
  • Fix missing std includes (memory, vector, string, cstring headers in multiple files)
  • Fix runtime format string handling for C++20 compatibility

Changes Made

  • ✅ Replaced all 12 instances of boost::format with osrm::util::compat::format
  • ✅ Removed boost::format constructor from util::exception class
  • ✅ Updated all format strings from boost style (%1%, %2%) to fmt style ({})
  • ✅ Added util/format.hpp includes where needed
  • ✅ Removed all #include <boost/format.hpp> directives
  • ✅ Fixed code formatting to match project style (include order, line wrapping)
  • ✅ Updated tar package to v7.5.9 to address GHSA-83g3-92jg-28cx security vulnerability
  • ✅ Added missing standard library includes to files that were relying on transitive includes via boost/format.hpp:
    • multi_level_partition.hpp (<memory>)
    • compressed_edge_container.hpp (<memory>)
    • io_config.hpp (<vector>)
    • tar.hpp (<cstring>, <string>)
    • shared_datatype.hpp (<string>)
    • io.hpp (<vector>)
    • shared_data_index.hpp (<vector>)
    • csv_file_parser.hpp (util/format.hpp)
  • ✅ Fixed runtime format string handling:
    • Added runtime_format (C++20) and runtime (fmt) to compat layer
    • Updated constrainParamSize functions to use runtime format wrappers
  • ✅ No remaining boost::format references in codebase
Original prompt

Replace boost::format with libfmt across the code base.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 18, 2026 10:02
Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>
Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>
Copilot AI changed the title [WIP] Replace boost::format with libfmt in code base Replace boost::format with libfmt Feb 18, 2026
Copilot AI requested a review from DennisOSRM February 18, 2026 10:05
@DennisOSRM
Copy link
Copy Markdown
Collaborator

@copilot fix formatting as reported in the failed CI job:


2026-02-18T10:04:11.3921957Z diff --git a/include/updater/csv_file_parser.hpp b/include/updater/csv_file_parser.hpp
2026-02-18T10:04:11.3922790Z index 53621c5..0a921e8 100644
2026-02-18T10:04:11.3923604Z --- a/include/updater/csv_file_parser.hpp
2026-02-18T10:04:11.3924018Z +++ b/include/updater/csv_file_parser.hpp
2026-02-18T10:04:11.3924622Z @@ -131,9 +131,8 @@ template <typename Key, typename Value> struct CSVFilesParser
2026-02-18T10:04:11.3925054Z          }
2026-02-18T10:04:11.3925423Z          catch (const boost::exception &e)
2026-02-18T10:04:11.3925718Z          {
2026-02-18T10:04:11.3926249Z -            const auto message = osrm::util::compat::format("exception in loading {}:\n {}",
2026-02-18T10:04:11.3926847Z -                                                            filename,
2026-02-18T10:04:11.3927390Z -                                                            boost::diagnostic_information(e));
2026-02-18T10:04:11.3927907Z +            const auto message = osrm::util::compat::format(
2026-02-18T10:04:11.3928511Z +                "exception in loading {}:\n {}", filename, boost::diagnostic_information(e));
2026-02-18T10:04:11.3929045Z              throw util::exception(message + SOURCE_REF);
2026-02-18T10:04:11.3929403Z          }
2026-02-18T10:04:11.3929690Z      }
2026-02-18T10:04:11.3930482Z diff --git a/include/util/mmap_file.hpp b/include/util/mmap_file.hpp
2026-02-18T10:04:11.3931158Z index b3e1f67..b517aad 100644
2026-02-18T10:04:11.3931628Z --- a/include/util/mmap_file.hpp
2026-02-18T10:04:11.3932182Z +++ b/include/util/mmap_file.hpp
2026-02-18T10:04:11.3933169Z @@ -29,9 +29,9 @@ util::vector_view<T> mmapFile(const std::filesystem::path &file, MmapContainerT
2026-02-18T10:04:11.3933862Z      }
2026-02-18T10:04:11.3934088Z      catch (const std::exception &exc)
2026-02-18T10:04:11.3934348Z      {
2026-02-18T10:04:11.3934788Z -        throw exception(osrm::util::compat::format("File {} mapping failed: {}", file.string(),
2026-02-18T10:04:11.3935313Z -                                                    exc.what()) +
2026-02-18T10:04:11.3935654Z -                        SOURCE_REF);
2026-02-18T10:04:11.3936030Z +        throw exception(
2026-02-18T10:04:11.3937134Z +            osrm::util::compat::format("File {} mapping failed: {}", file.string(), exc.what()) +
2026-02-18T10:04:11.3937915Z +            SOURCE_REF);
2026-02-18T10:04:11.3938275Z      }
2026-02-18T10:04:11.3938481Z  }
2026-02-18T10:04:11.3938643Z  
2026-02-18T10:04:11.3939103Z @@ -55,9 +55,9 @@ mmapFile(const std::filesystem::path &file, MmapContainerT &mmap_container, cons
2026-02-18T10:04:11.3939774Z      }
2026-02-18T10:04:11.3940225Z      catch (const std::exception &exc)
2026-02-18T10:04:11.3940513Z      {
2026-02-18T10:04:11.3940961Z -        throw exception(osrm::util::compat::format("File {} mapping failed: {}", file.string(),
2026-02-18T10:04:11.3941484Z -                                                    exc.what()) +
2026-02-18T10:04:11.3941812Z -                        SOURCE_REF);
2026-02-18T10:04:11.3942077Z +        throw exception(
2026-02-18T10:04:11.3942551Z +            osrm::util::compat::format("File {} mapping failed: {}", file.string(), exc.what()) +
2026-02-18T10:04:11.3942978Z +            SOURCE_REF);
2026-02-18T10:04:11.3943175Z      }
2026-02-18T10:04:11.3943345Z  }
2026-02-18T10:04:11.3943522Z  } // namespace detail
2026-02-18T10:04:11.3943992Z diff --git a/src/server/service/table_service.cpp b/src/server/service/table_service.cpp
2026-02-18T10:04:11.3944432Z index 88f7a8f..b6c8154 100644
2026-02-18T10:04:11.3944737Z --- a/src/server/service/table_service.cpp
2026-02-18T10:04:11.3945067Z +++ b/src/server/service/table_service.cpp
2026-02-18T10:04:11.3945324Z @@ -3,8 +3,8 @@
2026-02-18T10:04:11.3945578Z  #include "server/api/parameters_parser.hpp"
2026-02-18T10:04:11.3945901Z  #include "engine/api/table_parameters.hpp"
2026-02-18T10:04:11.3946161Z  
2026-02-18T10:04:11.3946383Z -#include "util/json_container.hpp"
2026-02-18T10:04:11.3946645Z  #include "util/format.hpp"
2026-02-18T10:04:11.3946914Z +#include "util/json_container.hpp"
2026-02-18T10:04:11.3947163Z  
2026-02-18T10:04:11.3947409Z  namespace osrm::server::service
2026-02-18T10:04:11.3947633Z  {
2026-02-18T10:04:11.3947897Z

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 18, 2026

@copilot fix formatting as reported in the failed CI job:

Fixed in 8876b37. Updated formatting to match project style:

  • csv_file_parser.hpp: Moved opening paren to separate line for multi-line format call
  • mmap_file.hpp: Adjusted line wrapping for both format calls (lines 32-34 and 58-60)
  • table_service.cpp: Reordered includes (util/format.hpp before util/json_container.hpp)

@DennisOSRM

This comment has been minimized.

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

This comment has been minimized.

@DennisOSRM

This comment has been minimized.

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

This comment has been minimized.

@DennisOSRM

This comment has been minimized.

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

This comment has been minimized.

@DennisOSRM

This comment has been minimized.

@DennisOSRM
Copy link
Copy Markdown
Collaborator

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

This comment has been minimized.

@DennisOSRM

This comment has been minimized.

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

This comment has been minimized.

@DennisOSRM

This comment has been minimized.

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

This comment has been minimized.

@DennisOSRM DennisOSRM marked this pull request as ready for review February 19, 2026 19:57
@DennisOSRM
Copy link
Copy Markdown
Collaborator

This was an interesting experiment in vibe coding. Arguably over the phone and not the most enjoyable experience, but it somehow worked.

@DennisOSRM DennisOSRM merged commit 362b388 into master Feb 21, 2026
19 checks passed
@DennisOSRM DennisOSRM deleted the copilot/replace-boost-format-with-libfmt branch February 21, 2026 19:36
MarcelloPerathoner pushed a commit to MarcelloPerathoner/osrm-backend that referenced this pull request Feb 24, 2026
* Initial plan

* Replace boost::format with libfmt across the codebase

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Remove unnecessary util/log.hpp include from shared_monitor.hpp

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Fix code formatting as reported by CI

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Fix npm audit security vulnerability in tar package

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Add missing <memory> include to multi_level_partition.hpp

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Add missing <memory> include to compressed_edge_container.hpp

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Add missing <vector> include to io_config.hpp

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Add missing <string> and <cstring> includes to storage headers

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Add missing includes: util/format.hpp and <vector>

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Fix runtime format string handling for C++20 std::format compatibility

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* [WIP] Fix build errors in project (Project-OSRM#7367)

* Fix clang-format-18 formatting in include/util/format.hpp (Project-OSRM#7368)

* Fix std::make_format_args rvalue binding error with GCC 13 (Project-OSRM#7369)

* Fix missing `<unistd.h>` include for macOS in io-benchmark (Project-OSRM#7370)

* Move `#ifdef OSRM_HAS_STD_FORMAT` from call sites into `format.hpp` (Project-OSRM#7371)

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>
Co-authored-by: Dennis Luxen <info@project-osrm.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants