Repository navigation
fix: three open issues that were filed because they change behaviour - #135
Merged
Merged
Conversation
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.
This was referenced Sep 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
initializeConfigwas not inside a try/catch, so any exception reachedstd::terminate, which flAPI binds to a handler that logs and then callsstd::abort(). A plain typo inflapi.yamlraised 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.
terminateHandlerstays for genuinely unexpected exceptions; that is what it is for.#127 — the global
rate_limitblock applied to nothingRateLimitMiddlewareread onlyendpoint->rate_limit. The global block was parsed and read by nobody, whileCONFIG_REFERENCEdocumented 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-valuewas ignored over MCPprepareParameterscarried a loop that read as "apply default values" with an inverted condition and an empty body.LIMIT {{ params.lim }}withdefault: "3"renderedLIMIT 3over REST andLIMITover 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:, notdefaultValue:. 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
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.