Skip to content

Reject a server: block, which flAPI never read (#153) - #161

Merged
jrosskopf merged 2 commits into
mainfrom
fix/gh-153-server-block-rejected
Sep 29, 2026
Merged

jrosskopf merged 2 commits into
mainfrom
fix/gh-153-server-block-rejected

Conversation

@jrosskopf

@jrosskopf jrosskopf commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

flAPI has no server: block, but server: {port, host} appeared in the config-system spec and in examples/flapi-bigquery-procedure.yaml. Nothing ever read it: an operator who set server.port: 9000 got a server on 8080, bound to 0.0.0.0, with no message.

A config containing a server: block now fails to start, with an error that names what to use. Closes #153.

flAPI has no `server:` block; it was never read, so anything set under it had no effect.
Configure the HTTP server with the top-level `http-port` and `http-host` keys, or with
--port/-p and --host, or the FLAPI_PORT and FLAPI_HOST environment variables.

Decisions (yours, from the plan)

Details

  • Presence, not shape. server: {port: 9000}, server: true and an empty server: all fail, with one message.
  • The message names every real way to set the server. The issue text listed only the port keys; host maps to http-host, which the message includes.
  • server-name is a different, real key and is unaffected. A test pins that.
  • Raised in parseMainConfig, so flapi --validate-config reports it (the command operators run in CI) and startup takes the clean exit from A config error aborts with a core dump (SIGABRT) instead of exiting cleanly #126, not an abort.
  • Fixed the BigQuery-procedure example (http-port / http-host, matching the s3/gcs/azure examples that were fixed earlier and this one missed) and the config-system spec. CONFIG_REFERENCE.md gets a note next to the port keys.

Codex review

Both reviewers requested changes; addressed:

Breaking-change note

Anyone with a server: block in their config will now fail to start. The changelog leads with the fix (http-port / http-host) and states that nothing working can be affected.

Test plan

  • Red first, on the unfixed binary: 9 of 13 failed: all six shapes, the message, the both-keys-set case and the example guard. The 4 fences passed (no error without a block; server-name unaffected; the glob finds the examples; the BigQuery example validates).
  • After the fix, the example guard failed on flAPI's own shipped BigQuery example, which is the guard doing its job. Now green.
  • A C++ unit test, checked red by temporarily disabling the check.
  • 796 C++ unit tests, 40 integration tests across the config, MCP, HTTPS, startup and security suites, and all build guards.

Found along the way, filed separately (not in this PR)

#
#156 --validate-config fails on examples/flapi.yaml: an MCP prompt file is validated as an endpoint. So those two examples can't be in the validation guard yet.
#157 Top-level environment-whitelist in the S3/GCS/Azure examples, where nothing reads it. Security-relevant, and the empty-whitelist meaning contradicts itself between two implementations.
#158 The dead https: block in CONFIG_REFERENCE §2.9 (real key: enforce-https).
#159 The flapii project init scaffold generates keys flAPI never reads.
#160 Warn on any unrecognised top-level key.

🤖 Generated with Claude Code

flAPI has no `server:` block. `server: {port, host}` appeared in the
config-system spec and in examples/flapi-bigquery-procedure.yaml, and nothing
ever read it: an operator who set `server.port: 9000` got a server on 8080,
bound to 0.0.0.0, with no message. The sibling s3/gcs/azure examples had been
fixed earlier; this one was missed.

Unlike the dead mcp.* keys of #151, which only warn, this is an error. A bind
port is the setting where "silently ignored" does the most damage - traffic
goes to the wrong place - and no value of `server:` has ever done anything, so
rejecting it cannot break a working configuration. The choice of an error over
a warning was the maintainer's; the alternative, honouring it as an alias, was
rejected because it would add a third way to set the port and contradict the
reference, which already said the block is not parsed.

Presence, not shape: `server: {port: 9000}`, `server: true` and an empty
`server:` are wrong for the same reason, so one message serves all of them. It
names every real way to set the server: the top-level http-port and http-host
keys, --port/-p and --host, FLAPI_PORT and FLAPI_HOST. The issue text listed
only the port keys; http-host is what `host` maps to. `server-name` is a
different, real key and is unaffected.

It is raised in parseMainConfig, so `flapi --validate-config` reports it - the
path operators run in CI - and startup takes the clean "flAPI cannot start until
the configuration is valid" exit (#126), not an abort.

Red first, on the unfixed binary: 9 of 13 failed - all six shapes, the message,
the both-keys-set case and the example guard - while the 4 fences passed (no
error without a block, `server-name` unaffected, the glob finds the examples,
the BigQuery example validates). After the fix the guard failed on flAPI's own
shipped example, which is the guard doing its job; the example now uses
http-port and http-host. A C++ unit test was checked red as well, by disabling
the check and watching it fail.

Deliberately not in this change, each filed on its own:
  #156 --validate-config rejects examples/flapi.yaml (an MCP prompt file is
       validated as an endpoint), so those two examples cannot be in the
       validation guard yet;
  #157 top-level environment-whitelist in the s3/gcs/azure examples, where
       nothing reads it - security-relevant, and the empty-whitelist meaning
       contradicts itself between two implementations;
  #158 the dead https: block in CONFIG_REFERENCE 2.9;
  #159 the `flapii project init` scaffold's dead keys;
  #160 warning on any unrecognised top-level key.

Closes #153
…break

From a Codex review of this PR (correctness and usability, both requested
changes).

The check ran after project-name, project-description and http-port were read.
A config with a `server:` block and one other mistake - a missing required key,
a malformed http-port - therefore reported only the other mistake, and the
operator fixed that and met this one on the next run. It now runs first, before
any other key is read. Red first: three new cases (no project-description, no
project-name, a non-numeric http-port, each alongside `server:`) failed on the
previous commit and pass now.

The changelog and the code comment both said rejecting the block "cannot" break
a working configuration. True of the server's behaviour - nothing under
`server:` ever had an effect - but a deployment whose config still carries the
block will no longer START, which is the whole point and the thing to warn
about. Both now say so.

Considered and not changed here:
  - `flapi pack` bundling a config it never validates - a real gap, but every
    config error behaves that way, not just this one; filed as #162.
  - YAML merge keys (`<<: *defaults`) hiding a `server:` key - yaml-cpp does
    not expand merge keys, so the same is true of http-port and every other
    key; noted on #162 and belongs with #160.
@jrosskopf
jrosskopf merged commit ee88a9c into main Sep 29, 2026
23 checks passed
@jrosskopf
jrosskopf deleted the fix/gh-153-server-block-rejected branch September 29, 2026 07:41
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.

A top-level server: block is documented and used in an example, but never read

1 participant