Skip to content

Commit 526fe94

Browse files
committed
ci: follow the runner's Visual Studio; reformat to satisfy clang-format-19
The Windows jobs pinned -G "Visual Studio 17 2022" and began failing with "could not find any instance of Visual Studio" once the runner image moved past it; both have been red since v3.4.4 while ubuntu and macos passed. Drop the explicit generator so CMake picks whatever Visual Studio the image ships. The format-check job had been red for as long, on 23 files. Reformatted with clang-format-19 using the repo's own .clang-format. Purely mechanical: the full suite is 112/112 after it.
1 parent f915183 commit 526fe94

24 files changed

Lines changed: 192 additions & 168 deletions

‎.github/workflows/ci.yml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,15 @@ jobs:
4343
4444
- name: Configure (Windows)
4545
if: runner.os == 'Windows'
46+
# No explicit -G: pinning "Visual Studio 17 2022" broke the moment the
47+
# runner image moved past it ("could not find any instance of Visual
48+
# Studio"). CMake's default generator on a Windows runner is the newest
49+
# installed Visual Studio, so this follows the image instead of chasing
50+
# it. -A x64 still applies -- the default generator is a VS one, which
51+
# is also what the MSBuild flags in the build step below require.
4652
run: |
4753
if (Test-Path build) { Remove-Item -Recurse -Force build/CMakeCache.txt, build/CMakeFiles -ErrorAction SilentlyContinue }
48-
cmake -B build -S . -G "Visual Studio 17 2022" -A x64 -DFASTMCPP_BUILD_TESTS=ON -DFASTMCPP_BUILD_EXAMPLES=ON
54+
cmake -B build -S . -A x64 -DFASTMCPP_BUILD_TESTS=ON -DFASTMCPP_BUILD_EXAMPLES=ON
4955
5056
- name: Build (Unix)
5157
if: runner.os != 'Windows'

‎include/fastmcpp/providers/openapi_provider.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ class OpenAPIProvider : public Provider
3535
// Absent style => "form"; absent explode => true (the OpenAPI query defaults).
3636
struct ParameterMeta
3737
{
38-
std::string style; // "form" | "spaceDelimited" | "pipeDelimited"
39-
std::optional<bool> explode; // nullopt => default (true)
38+
std::string style; // "form" | "spaceDelimited" | "pipeDelimited"
39+
std::optional<bool> explode; // nullopt => default (true)
4040
};
4141

4242
struct RouteDefinition

‎include/fastmcpp/server/host_origin_guard.hpp‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,14 @@ class HostOriginGuard
8181
const std::optional<std::string>& origin_header,
8282
const std::string& scheme, const std::string& bound_host) const;
8383

84-
bool enabled() const { return options_.mode != HostOriginProtectionMode::Off; }
85-
const HostOriginGuardOptions& options() const { return options_; }
84+
bool enabled() const
85+
{
86+
return options_.mode != HostOriginProtectionMode::Off;
87+
}
88+
const HostOriginGuardOptions& options() const
89+
{
90+
return options_;
91+
}
8692

8793
private:
8894
bool should_validate_host(const std::string& bound_host) const;
@@ -100,7 +106,6 @@ class HostOriginGuard
100106
/// Install the guard as an httplib pre-routing handler: it runs before ALL routes
101107
/// (including OPTIONS), before auth and session handling. No-op when mode == Off.
102108
/// `bound_host` should be the wrapper's bound address (drives Auto-mode decisions).
103-
void install_host_origin_guard(httplib::Server& svr, HostOriginGuard guard,
104-
std::string bound_host);
109+
void install_host_origin_guard(httplib::Server& svr, HostOriginGuard guard, std::string bound_host);
105110

106111
} // namespace fastmcpp::server

‎include/fastmcpp/server/middleware_pipeline.hpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,7 @@ class RateLimitingMiddleware : public Middleware
535535
{
536536
}
537537
explicit RateLimitingMiddleware(Config config)
538-
: config_(std::move(config)),
539-
global_{config_.max_tokens, std::chrono::steady_clock::now()}
538+
: config_(std::move(config)), global_{config_.max_tokens, std::chrono::steady_clock::now()}
540539
{
541540
}
542541

@@ -572,7 +571,8 @@ class RateLimitingMiddleware : public Middleware
572571
bool consume(Bucket& b, std::chrono::steady_clock::time_point now)
573572
{
574573
auto elapsed = std::chrono::duration<double>(now - b.last_refill);
575-
b.tokens = std::min(config_.max_tokens, b.tokens + elapsed.count() * config_.tokens_per_second);
574+
b.tokens =
575+
std::min(config_.max_tokens, b.tokens + elapsed.count() * config_.tokens_per_second);
576576
b.last_refill = now;
577577
if (b.tokens >= 1.0)
578578
{

‎src/app.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#include "fastmcpp/exceptions.hpp"
66
#include "fastmcpp/mcp/handler.hpp"
77
#include "fastmcpp/providers/provider.hpp"
8-
#include "fastmcpp/server/middleware_pipeline.hpp"
98
#include "fastmcpp/resources/template.hpp"
9+
#include "fastmcpp/server/middleware_pipeline.hpp"
1010
#include "fastmcpp/util/http_methods.hpp"
1111
#include "fastmcpp/util/json_schema.hpp"
1212
#include "fastmcpp/util/schema_build.hpp"

‎src/client/sampling_handlers.cpp‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,7 @@ static fastmcpp::Json build_openai_content_parts(const fastmcpp::Json& content)
261261
const std::string t = block.value("type", "");
262262
if (t == "text")
263263
{
264-
parts.push_back(
265-
fastmcpp::Json{{"type", "text"}, {"text", block.value("text", "")}});
264+
parts.push_back(fastmcpp::Json{{"type", "text"}, {"text", block.value("text", "")}});
266265
}
267266
else if (t == "image")
268267
{
@@ -341,7 +340,8 @@ static fastmcpp::Json build_openai_messages(const fastmcpp::Json& params)
341340
if (role != "user")
342341
throw std::runtime_error(
343342
"OpenAI sampling handler: image/audio content is only supported in user "
344-
"messages (got role '" + role + "')");
343+
"messages (got role '" +
344+
role + "')");
345345
messages.push_back(
346346
fastmcpp::Json{{"role", "user"}, {"content", build_openai_content_parts(content)}});
347347
continue;
@@ -501,16 +501,17 @@ static fastmcpp::Json build_anthropic_messages(const fastmcpp::Json& params)
501501
if (role != "user")
502502
throw std::runtime_error(
503503
"Anthropic sampling handler: image content is only supported in user "
504-
"messages (got role '" + role + "')");
504+
"messages (got role '" +
505+
role + "')");
505506
const std::string mime = block.value("mimeType", "");
506507
if (!anthropic_image_mime_ok(mime))
507508
throw std::runtime_error(
508509
"Anthropic sampling handler: unsupported image MIME '" + mime + "'");
509-
blocks.push_back(fastmcpp::Json{
510-
{"type", "image"},
511-
{"source", fastmcpp::Json{{"type", "base64"},
512-
{"media_type", mime},
513-
{"data", block.value("data", "")}}}});
510+
blocks.push_back(
511+
fastmcpp::Json{{"type", "image"},
512+
{"source", fastmcpp::Json{{"type", "base64"},
513+
{"media_type", mime},
514+
{"data", block.value("data", "")}}}});
514515
continue;
515516
}
516517
if (type == "audio")

‎src/mcp/handler.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2591,8 +2591,8 @@ make_mcp_handler(const FastMCP& app, SessionAccessor session_accessor)
25912591

25922592
// Phase 4: run the registered Middleware pipeline around dispatch. With no middleware
25932593
// registered (the default), `core` is invoked directly — byte-identical, zero overhead.
2594-
return [&app, core = std::move(core), session_accessor](
2595-
const fastmcpp::Json& message) -> fastmcpp::Json
2594+
return [&app, core = std::move(core),
2595+
session_accessor](const fastmcpp::Json& message) -> fastmcpp::Json
25962596
{
25972597
if (!app.has_middleware())
25982598
return core(message);
@@ -2617,8 +2617,8 @@ make_mcp_handler(const FastMCP& app, SessionAccessor session_accessor)
26172617
else if (ctx.method == "prompts/get")
26182618
ctx.prompt_name = params.value("name", "");
26192619

2620-
return app.middleware_pipeline()->execute(
2621-
ctx, [&core](const server::MiddlewareContext& c) { return core(c.message); });
2620+
return app.middleware_pipeline()->execute(ctx, [&core](const server::MiddlewareContext& c)
2621+
{ return core(c.message); });
26222622
};
26232623
}
26242624

‎src/providers/openapi_provider.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ Json OpenAPIProvider::invoke_route(const RouteDefinition& route, const Json& arg
576576
{
577577
part.filename = to_string_value(v["filename"]);
578578
part.content = v["content"].is_string() ? v["content"].get<std::string>()
579-
: to_string_value(v["content"]);
579+
: to_string_value(v["content"]);
580580
if (v.contains("contentType") && v["contentType"].is_string())
581581
part.content_type = v["contentType"].get<std::string>();
582582
}

‎src/server/host_origin_guard.cpp‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33

44
#include "fastmcpp/server/host_origin_guard.hpp"
55

6-
#include <httplib.h>
7-
86
#include <algorithm>
97
#include <array>
108
#include <cctype>
119
#include <cstdint>
10+
#include <httplib.h>
1211

1312
namespace fastmcpp::server
1413
{
@@ -89,8 +88,8 @@ bool parse_ipv6(const std::string& s, std::array<uint8_t, 16>& out)
8988
while (true)
9089
{
9190
size_t colon = part.find(':', start);
92-
std::string g =
93-
(colon == std::string::npos) ? part.substr(start) : part.substr(start, colon - start);
91+
std::string g = (colon == std::string::npos) ? part.substr(start)
92+
: part.substr(start, colon - start);
9493
if (g.empty())
9594
return false; // empty group outside of "::"
9695
groups.push_back(g);
@@ -554,22 +553,19 @@ HostOriginVerdict HostOriginGuard::check(const std::string& host_header,
554553
return HostOriginVerdict::Allow;
555554
}
556555

557-
void install_host_origin_guard(httplib::Server& svr, HostOriginGuard guard,
558-
std::string bound_host)
556+
void install_host_origin_guard(httplib::Server& svr, HostOriginGuard guard, std::string bound_host)
559557
{
560558
if (!guard.enabled())
561559
return;
562560
svr.set_pre_routing_handler(
563561
[guard = std::move(guard), bound_host = std::move(bound_host)](
564-
const httplib::Request& req,
565-
httplib::Response& res) -> httplib::Server::HandlerResponse
562+
const httplib::Request& req, httplib::Response& res) -> httplib::Server::HandlerResponse
566563
{
567564
std::optional<std::string> origin;
568565
if (req.has_header("Origin"))
569566
origin = req.get_header_value("Origin");
570567
// fastmcpp serves plain HTTP; TLS termination happens upstream.
571-
auto verdict =
572-
guard.check(req.get_header_value("Host"), origin, "http", bound_host);
568+
auto verdict = guard.check(req.get_header_value("Host"), origin, "http", bound_host);
573569
if (verdict == HostOriginVerdict::RejectHost421)
574570
{
575571
res.status = 421;

‎src/util/json_schema.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ static void strip_discriminator(Json& node)
224224
{
225225
// Before dropping the discriminator hint, keep its property REQUIRED in each variant.
226226
// Mirrors Python `_require_property` (commits 9b1a1a04 / 5fa4f32c, #4297 / #4362): strict
227-
// validators would otherwise no longer enforce the discriminator field once the hint is gone.
227+
// validators would otherwise no longer enforce the discriminator field once the hint is
228+
// gone.
228229
const Json& disc = node["discriminator"];
229230
if (disc.is_object() && disc.contains("propertyName") && disc["propertyName"].is_string())
230231
{

0 commit comments

Comments
 (0)