Skip to content

fix: three open issues that were filed because they change behaviour - #135

Merged
jrosskopf merged 2 commits into
mainfrom
fix/open-issues-batch-a
Sep 22, 2026
Merged

jrosskopf merged 2 commits into
mainfrom
fix/open-issues-batch-a

Conversation

@jrosskopf

@jrosskopf jrosskopf commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Closes #124, #126, #127.

Each was filed rather than fixed because the fix is observable. Taken together now, with the change stated per issue.

#126 — a config error aborted with a core dump

initializeConfig was not inside a try/catch, so any exception reached std::terminate, which flAPI binds to a handler that logs and then calls std::abort(). A plain typo in flapi.yaml raised SIGABRT, dumped core, and exited 134 — reported as a crash in a container, and writing a dump of a ~77 MB binary on every restart attempt.

Change: exit code 134 → 1. terminateHandler stays for genuinely unexpected exceptions; that is what it is for.

#127 — the global rate_limit block applied to nothing

RateLimitMiddleware read only endpoint->rate_limit. The global block was parsed and read by nobody, while CONFIG_REFERENCE documented four keys under it and called them global. Measured: a global limit of 2 let requests 3 and 4 straight through with no 429 at all.

Per-endpoint rate-limit: still wins; the global block now applies to endpoints that declare none.

Change: deployments that set the global block and are unlimited today will start returning 429s. That is the documented behaviour finally happening — but it is a change, and the one in this PR most likely to be noticed.

#124 — default-value was ignored over MCP

prepareParameters carried a loop that read as "apply default values" with an inverted condition and an empty body. LIMIT {{ params.lim }} with default: "3" rendered LIMIT 3 over REST and LIMIT over MCP — a parser error, or an unbounded query.

Change: MCP tools now receive defaults they did not receive before.

Tests

The MCP tests assert the two protocols agree, rather than checking the MCP side alone — the failure was them drifting apart, and a one-sided assertion would not catch a recurrence. The rate-limit tests cover both that the global block applies and that a per-endpoint block still overrides it, since inverting that precedence is the obvious way to get this wrong.

747 unit, 370 standalone integration, all green. No existing test modified.

One note for anyone reproducing

The config key is default:, not defaultValue:. I used the latter first and both protocols returned a parser error — which is how I noticed my fixture was wrong rather than the fix. Worth knowing, because a one-sided test would have shown MCP "working" here for the wrong reason.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Each was filed rather than fixed because the fix is observable. Taken
together now, with the change stated per issue.

#126 - a config error aborted with a core dump.

  initializeConfig was not inside a try/catch, so any exception it threw
  reached std::terminate, which flAPI binds to a handler that logs and then
  calls std::abort(). A plain typo in flapi.yaml raised SIGABRT, dumped
  core and exited 134 - reported as a crash in a container, and writing a
  dump of a ~77 MB binary on every restart attempt.

  Now caught, reported, and exit 1. terminateHandler stays for genuinely
  unexpected exceptions; that is what it is for.

  CHANGE: exit code 134 -> 1 for a configuration error.

#127 - the global rate_limit block applied to nothing.

  RateLimitMiddleware read only endpoint->rate_limit. The global block was
  parsed into ConfigManager::rate_limit_config and read by nobody, while
  CONFIG_REFERENCE documented four keys under it and called them global. An
  operator configuring deployment-wide limiting got none, with no warning:
  measured, a global limit of 2 let requests 3 and 4 straight through with
  no 429 at all.

  Per-endpoint rate-limit: still wins; the global block now applies to
  endpoints that declare none.

  CHANGE: deployments that set the global block and are unlimited today
  will start returning 429s. That is the documented behaviour finally
  happening, but it is a change.

#124 - default-value was ignored over MCP.

  prepareParameters carried a loop that read as "apply default values" with
  an inverted condition and an empty body. A template writing
  `LIMIT {{ params.lim }}` with `default: "3"` rendered LIMIT 3 over REST
  and `LIMIT ` over MCP - a parser error or an unbounded query.

  CHANGE: MCP tools now receive default values they did not receive before.

Tests assert the two protocols AGREE rather than checking the MCP side
alone, since the failure was them drifting apart. The rate-limit tests
cover both that the global block applies and that a per-endpoint block
still overrides it - precedence inverting would be the obvious way to get
this wrong.

Note for anyone reproducing: the config key is `default:`, not
`defaultValue:`. I wrote the latter first, and BOTH protocols then returned
a parser error - which is how I noticed the test fixture was wrong rather
than the fix.

747 unit tests, 370 standalone integration tests.
Three high findings against my own change, all confirmed against the code
before acting on them.

F1 - `rate-limit: {enabled: false}` could not opt out of the global limit.

  parseEndpointRateLimit only writes when the block exists, but `enabled`
  defaults to false either way, so an explicit opt-out was indistinguishable
  from "never mentioned it" - and my ternary therefore routed the opt-out to
  the global limit, the opposite of what the config says.

  RateLimitConfig gains a `declared` flag. The middleware treats
  `declared || enabled` as endpoint ownership, deliberately: six existing
  unit tests build RateLimitConfig in code and set only `enabled`, and
  keying on `declared` alone made them fail. Those tests are correct - the
  invariant was mine, and a two-field rule that is silently wrong when only
  one is set is a bad design, not a bad test. So the check tolerates either.

F2 - MCP validated before applying defaults; REST applies them first.

  My #124 fix closed one asymmetry and left another: a required field
  carrying a `default:` passed validation over REST and failed it over MCP.
  Defaults now go in before validateToolArguments, matching
  combineParameters -> RequestValidator on the REST side.

F3 - the precedence test configured no global block.

  It asserted an endpoint limit of 5 worked with no global block present,
  which tests nothing about precedence. It now sets both, and different:
  endpoint 5, global 1, and asserts the endpoint wins. Plus a case for the
  opt-out from F1, which had no coverage at all.

747 unit tests, 372 standalone integration tests.
@jrosskopf
jrosskopf merged commit 23bd0f0 into main Sep 22, 2026
22 checks passed
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.

default-value is applied over REST and ignored over MCP

1 participant