Skip to content

fix(server): config precedence, boolean switches, and docs for what exists - #1944

Merged
bplatz merged 7 commits into
mainfrom
fix/server-config-docs
Sep 28, 2026
Merged

bplatz merged 7 commits into
mainfrom
fix/server-config-docs

Conversation

@bplatz

@bplatz bplatz commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Docs: server flags and capabilities that exist

Many operations, API and troubleshooting docs described server flags that don't exist and started the server as a bare binary. I checked every flag against fluree server run --help, the server's config.rs (including feature-gated flags) and the CLI source, and ran several of the changed commands against the built binaries.

  • How the server is started. Every example now uses fluree server run. Server flags that run doesn't take itself go after --, e.g. fluree server run --storage-path /var/lib/fluree -- --cache-max-mb 4096.
    • A few examples in quickstart-server.md and docker.md were missing the -- and would have failed.
    • The standalone fluree-server binary is kept only where it's required (Raft) or where the doc is about building from source.
  • Invented flags mapped to real ones:
    • --port → --listen-addr
    • --storage file --data-dir → --storage-path
    • S3/DynamoDB flags → --connection-config
    • the size-limit flags per request kind → one --body-limit
    • --cache-size-mb → --cache-max-mb
    • --require-auth → the --*-auth-mode flags
    • --log-format → LOG_FORMAT
  • Capabilities the server doesn't have now say so, and point to a reverse proxy where that fits: TLS termination, rate limiting and X-RateLimit headers, CORS allow-lists (CORS is on/off and allows any origin), response size limits.
  • Also corrected:
    • the FLUREE_REINDEX_MIN_BYTES default;
    • the /health and /stats response shapes;
    • the export URL;
    • "memory storage is the default" (it's file storage in .fluree/);
    • the OTEL environment variable defaults;
    • boolean switches (--cors-enabled, --indexing-enabled) can only be turned off by env var or config file;
    • the oidc feature needs a custom CLI build;
    • Raft runs only in the standalone binary.

26 docs changed. The full list is in the first commit.

Fix: config precedence

The docs promise flag > env var > profile > config file > default. Two bugs broke that for the storage path and for explicit config files:

  • FLUREE_STORAGE_PATH and profile storage_path were ignored under fluree server run. The CLI always passed a default --storage-path, which beat both. It now leaves the storage path to the server's own precedence and fills in .fluree/storage only when nothing else set one.
  • An explicit config file was never loaded. Both fluree server run --config <file> and fluree-server --config-file <file> were affected. resolve_config_path tested is_dir() twice where the first check should have been is_file(), so it logged "not found" and carried on with defaults. This has been the case since the v4 baseline. The file is loaded now, and a named config file that doesn't exist is an error, which both entry points already treat as fatal (and which the docs already promised).

Fix: --cors-enabled / --indexing-enabled accept =false

Both default to on, and as plain clap switches they could only turn things on: --cors-enabled=false was rejected. They now take an optional value (--cors-enabled=false, =0, =off), and the bare flag still means true. This also fixes the env vars: the old definition accepted exactly true or false, so FLUREE_INDEXING_ENABLED=0 (or =off, =no) stopped the server from starting. Clap's boolish parser now accepts 1/0, yes/no, on/off and the like, in any case.

The other boolean flags default to off, so I left them unchanged.

Docs: IPFS is Rust-API-only; connection config examples that parse

  • IPFS. IPFS storage exists only through FlureeBuilder::build_ipfs, which keeps the nameservice in memory: the blocks persist, but ledgers don't survive a restart.
    • The docs presented it as a server storage mode set up in a connection config (ipfsApiUrl, ipfsPinOnPut, env var indirection). None of that is parsed.
    • Worse, such a config silently became memory storage.
    • The IPFS guide, the storage modes page and the connection config reference now describe what exists. A storage node with ipfsApiUrl is rejected with an error that points to the Rust API.
    • build_ipfs's rustdoc said to compose IpfsStorage with a persistent nameservice via build_with. That can't work: IpfsStorage doesn't implement Storage. The rustdoc now says so.
  • Connection config examples. The config graph indexes nodes by @id, so a Connection node without one fails with "No Connection node found". That affected the storage encryption examples (file and S3) and the Rust encryption example; all now carry one. The addressIdentifiers fragment is now a complete config.
  • Every connection config example in the docs (11) was extracted and run through FlureeBuilder::from_json_ld. All parse.

Testing

  • fluree-db-cli: storage_path_precedence checks flag > env > profile > config file > default through build_server_config, against a real config file.
  • fluree-db-server:
    • explicit_config_file_is_loaded_or_fails;
    • default_on_switches_take_an_explicit_value.
  • fluree-db-connection: ipfs_storage_node_is_rejected_not_memory.
  • Each test fails with its fix reverted.
  • On the committed state, checked in a clean worktree:
    • cargo fmt --all --check;
    • cargo clippy -p fluree-db-connection -p fluree-db-server -p fluree-db-api -p fluree-db-cli --all-features --all-targets -- -D warnings;
    • the wasm32 clippy gate;
    • 468 connection/server/CLI lib tests;
    • earlier, the full fluree-db-cli suite (442 tests).
  • Review follow-ups: fmt, clippy on fluree-db-connection and fluree-db-server, their 242 lib tests, and mdbook build.

Review follow-ups

  • --cache-max-mb help said 50% of RAM at ≥8GB; it now says 35%, matching the code and the docs.
  • docs/api/headers.md documented headers the server never reads or sends. It now lists the fluree-* request headers and x-fdb-* tracking headers that exist, and says the server has none of these:
    • X-Fluree-Fuel-Limit (it's fluree-max-fuel), X-Fluree-Policy (fluree-policy), X-Response-Time (x-fdb-time, when tracked);
    • X-Fluree-Timeout — the query timeout is server-wide, FLUREE_QUERY_TIMEOUT_MS, which common-errors.md now uses too;
    • X-Fluree-T, X-Fluree-Commit, an echoed X-Request-ID, and ETag/Cache-Control/conditional requests on queries;
    • request and response compression (none; use a reverse proxy).
  • The IPFS field IRI moved into vocab as FIELD_IPFS_API_URL, and parse_storage_node got its doc comment back.
  • docs/operations/configuration.md lists the spellings FLUREE_CORS_ENABLED / FLUREE_INDEXING_ENABLED and their flags accept.
  • A storage node with both a real backend and ipfsApiUrl still parses as that backend: rejecting it would turn a working config with a leftover key into a startup failure.

Upgrade note

fluree server run now honors FLUREE_STORAGE_PATH and a profile's storage_path; before, it overrode both with .fluree/storage. If either is set in your environment or profile and you did not expect it to apply, unset it before upgrading, or the server starts against that directory instead.

@bplatz bplatz added bug Something isn't working as expected area:server HTTP surface, routes, error mapping, swagger, timeouts/admission, config graph area:cli fluree CLI UX, rdf toolkit, publish/export/insert flows labels Sep 25, 2026
@bplatz
bplatz requested review from aaj3f and zonotope September 25, 2026 16:07
@bplatz
bplatz added this pull request to stack #1922 September 25, 2026 16:07
@bplatz bplatz changed the title fix(server): config precedence and docs for the server flags that exist fix(server): config precedence, boolean switches, and docs for what exists Sep 25, 2026
@bplatz
bplatz removed this pull request from stack #1922 September 25, 2026 18:27
@bplatz
bplatz force-pushed the fix/server-config-docs branch from 08cee5c to 43be82a Compare September 25, 2026 19:15
@bplatz
bplatz added this pull request to stack #1947 September 25, 2026 19:15
@bplatz
bplatz force-pushed the fix/server-config-docs branch 2 times, most recently from 5eb2cb7 to ebb0ef8 Compare September 25, 2026 21:07
@bplatz
bplatz force-pushed the fix/server-config-docs branch 2 times, most recently from b33a9d0 to fa53edf Compare September 25, 2026 21:31
@bplatz
bplatz force-pushed the fix/server-config-docs branch 3 times, most recently from e7ffbd8 to b51f9af Compare September 25, 2026 23:13
@bplatz
bplatz force-pushed the fix/server-config-docs branch from b51f9af to b958f29 Compare September 25, 2026 23:32
@bplatz
bplatz force-pushed the fix/server-config-docs branch from b958f29 to 29d8c4a Compare September 25, 2026 23:37
@bplatz
bplatz force-pushed the fix/server-config-docs branch from 29d8c4a to cba69a1 Compare September 25, 2026 23:52
@bplatz
bplatz force-pushed the fix/server-config-docs branch from cba69a1 to 55bf523 Compare September 26, 2026 00:45
@bplatz
bplatz force-pushed the fix/server-config-docs branch 2 times, most recently from 5929335 to 28ab9a1 Compare September 26, 2026 01:06
@bplatz
bplatz force-pushed the fix/server-config-docs branch 2 times, most recently from 1265f26 to fe054bf Compare September 26, 2026 01:51
@bplatz
bplatz force-pushed the fix/server-config-docs branch 4 times, most recently from a7610b1 to d41223a Compare September 26, 2026 03:42
Base automatically changed from feat/construct-turtle-output to main September 26, 2026 09:38
@bplatz
bplatz force-pushed the fix/server-config-docs branch from d41223a to 3f56048 Compare September 26, 2026 09:38
Many operations, API and troubleshooting docs showed server flags that do
not exist (--port, --storage, --data-dir, S3/DynamoDB flags, --tls-*,
--require-auth, rate limiting, CORS allow-lists, size limits per request
kind) and ran the server as a bare binary. Every example now uses
`fluree server run`, passing flags it does not take itself after `--`, and
maps each invented flag to the real one (--listen-addr, --storage-path,
--connection-config, --body-limit, --cache-max-mb, the --*-auth-mode
flags) or says plainly that the capability belongs in a reverse proxy.

Also documented: `fluree server run` overrides FLUREE_STORAGE_PATH, the
boolean switches can only be turned off by env var or config file, the
oidc feature needs a custom CLI build, and Raft runs only in the
standalone fluree-server binary.
…ig files

`fluree server run` passed a default `--storage-path` whenever none was
given, so the flag beat `FLUREE_STORAGE_PATH` and any profile's
`storage_path`. It now leaves the storage path to the server's precedence
(flag, env var, profile, config file) and fills in the project's
`.fluree/storage` only when none of those set one.

An explicit config file (`fluree server run --config <file>`,
`fluree-server --config-file <file>`) was never loaded: the path check
tested `is_dir()` twice instead of `is_file()`, logged a warning and
carried on with defaults. It is loaded now, and a named config file that
doesn't exist is an error, as the configuration docs already said.
…parse

IPFS storage is reachable only through `FlureeBuilder::build_ipfs`, which
keeps the nameservice in memory, so ledgers do not survive a restart. The
docs presented it as a server storage mode configured through a
connection config (`ipfsApiUrl`, `ipfsPinOnPut`, env var indirection),
none of which is parsed. Worse, such a config silently became memory
storage. The IPFS guide, storage modes page and connection config
reference now describe what exists, and a storage node with `ipfsApiUrl`
is rejected with an error pointing to the Rust API.

Connection config examples whose Connection node had no `@id` failed with
"No Connection node found" (the config graph indexes nodes by `@id`); the
storage encryption examples and the Rust encryption example now carry
one, and the `addressIdentifiers` fragment is a complete config. Every
connection config example in the docs was run through
`FlureeBuilder::from_json_ld`.
Both default to on, and as plain clap switches they could only be turned
on: `--cors-enabled=false` was rejected, so switching them off took an
env var or the config file. They now take an optional value
(`--cors-enabled=false`, `=0`, `=off`); the bare flag still means true.
The value parser is clap's boolish one, so existing `FLUREE_*=0` style
env settings keep working.

@aaj3f aaj3f left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bplatz 👍 🚀 -- I do think there's maybe 2 things from your "Found, not changed here" list that I, personally, would still advocate do get changed/done here, and I've included those below, but otherwise full agreement & looks good. Entire review below for your consideration:


The resolve_config_path find is the kind of thing that hides forever: is_dir() twice where the first should have been is_file(), so --config <file> was ignored outright and --config <dir> resolved to a path that couldn't load. That's been broken since the v4 baseline and nothing surfaced it. The storage-path fix is the right shape too — taking the CLI out of the precedence ladder rather than teaching it to imitate the server's, so there's one resolver instead of two that can disagree.

I verified the substance rather than reading it: all four new tests pass in a clean worktree, and I mutation-checked them — reverting is_file() back to is_dir() turns both explicit_config_file_is_loaded_or_fails and the CLI's storage_path_precedence red, so they're non-vacuous. I also traced the ValueSource gating in apply_to_server_config (config_file.rs:508) to satisfy myself that the documented flag > env > profile > file > default order is the implemented one, checked that default_storage_path() and the server's config-file discovery read the same [server].storage_path from the same .fluree/ walk so the handoff loses nothing, and swept every consumer of the two boolean flags — including build_child_args — for a space-separated form that require_equals would now break. There isn't one.

Two things I'd like folded in, both from your own "Found, not changed here" list, and both stronger than they look because of how this PR works:

  • fluree-db-server/src/config.rs:498 — --help still says --cache-max-mb is 50% of RAM at ≥8GB; the code is 35% (fluree-db-connection/src/cache.rs:35) and the docs you're shipping say 35% in five places. You validated the docs against --help, so this merges as the one artifact that disagrees with the corrected docs. It's a 50% → 35% edit in a file you're already in.
  • docs/api/headers.md — X-Fluree-Fuel-Limit, X-Fluree-Timeout and X-Response-Time are still documented, and I confirmed zero .rs hits for all three. It's the file the finding lives in and you're editing it; the same treatment you gave TLS and rate limiting would drop right in.

Beyond those: the doc comment above the new IPFS_API_URL const (fluree-db-connection/src/config.rs:485) picked up parse_storage_node's /// line, so the const is documented and the function isn't — one-line move. And two notes rather than asks: FLUREE_STORAGE_PATH beginning to take effect deserves an upgrade note, since a stale one in someone's environment now silently moves their storage directory; and the boolean change is a bigger win than the body says — I probed it, and the old definition rejected FLUREE_CORS_ENABLED=0 / =off / =no with a hard startup error rather than honoring them, so you've fixed that too.

The silent-memory-storage bug is the sharpest thing in here and the body undersells it — a user who configured ipfsApiUrl got a server that looked healthy and lost everything on restart. Nice catch.

Adherence to repo commitments

  • Patterns / abstractions — ✔ with one ⚪: extends ServerConfig's existing clap surface and the established is_default/ValueSource merge rather than adding a parallel path; the CLI correctly stops duplicating the server's resolver. The bare IPFS_API_URL const sidesteps the vocab::FIELD_* convention two lines below it.
  • Performance (speed first, memory second) — ✔ No performance-degradation risk. Everything touched runs at process start (clap parse, config-file read, connection-config parse) or in the CLI. No query, transaction, or index path; no allocation, clone, lock, or .collect() added to any loop. The one new probe (node.get(IPFS_API_URL)) runs once per storage node at connection build.
  • Testing — ✔ four new tests, all wired into crate targets that run, all passing, and mutation-checked non-vacuous. storage_path_precedence covers the full ladder against a real config file, which is the right level for this fix.
  • Conventions — ✔ self-describing subjects with substantive multi-line bodies; fmt and clippy clean per CI on 741fd78be (16 checks, all non-skipped green); docs updated in step with the behavior, including the boolean forms the final commit enables.

Approving so you can merge when ready — but I'd really like the two --help / headers.md items in before it lands, since they're the two places this PR's own premise doesn't quite close. Happy to talk through any of these.

Comment thread fluree-db-connection/src/config.rs Outdated
}

/// Parse storage config from a resolved JSON-LD node
/// Recognized only to reject it: see [`parse_storage_node`].

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 LOW-1 — the new const absorbed parse_storage_node's doc comment

I think the insertion landed one line too high here — /// Parse storage config from a resolved JSON-LD node was parse_storage_node's doc comment, and now it documents IPFS_API_URL instead, so the const has a two-line doc that reads as a contradiction and the function has none:

/// Parse storage config from a resolved JSON-LD node
/// Recognized only to reject it: see [`parse_storage_node`].
const IPFS_API_URL: &str = "https://ns.flur.ee/system#ipfsApiUrl";

fn parse_storage_node(graph: &ConfigGraph, node: &JsonValue) -> Result<StorageConfig> {

Both are private so nothing catches it, but it's a one-move fix:

/// Recognized only to reject it: see [`parse_storage_node`].
const IPFS_API_URL: &str = "https://ns.flur.ee/system#ipfsApiUrl";

/// Parse storage config from a resolved JSON-LD node
fn parse_storage_node(graph: &ConfigGraph, node: &JsonValue) -> Result<StorageConfig> {

(Shown as a block rather than a suggestion because it spans several lines and the anchor is single-line — applying it as a one-click suggestion would duplicate the surrounding code.)

Comment thread fluree-db-connection/src/config.rs Outdated

/// Parse storage config from a resolved JSON-LD node
/// Recognized only to reject it: see [`parse_storage_node`].
const IPFS_API_URL: &str = "https://ns.flur.ee/system#ipfsApiUrl";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ NIT-2 — IPFS_API_URL sits outside the vocab::FIELD_* convention

More of a question than a suggestion: every other field IRI in this file comes through the vocab module — the very next line of parse_storage_node reads resolve_string(graph, node, vocab::FIELD_ADDRESS_IDENTIFIER). I wonder if this one wants to be vocab::FIELD_IPFS_API_URL too, so there's one place to look when the system vocab moves. It genuinely may not be worth it given the constant exists only to be rejected — happy to be told that's the point.

});
}

// IPFS storage is not built from connection configs (only the Rust API's

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ NIT-3 — a node with ipfsApiUrl and a real backend silently ignores the IPFS key

The check sits after the S3/file/DynamoDB branches and just before the memory fallback, which is exactly right for the bug you're fixing (IPFS → silent memory). It does mean a node carrying both s3Bucket and ipfsApiUrl parses as S3 and drops the IPFS key without a word. That's a strictly better outcome than today and I don't think it's worth restructuring for — noting it only so the placement is a decision rather than an accident.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deliberate. Rejecting every node that carries ipfsApiUrl would turn a working S3, file or DynamoDB config with a leftover key into a startup failure on upgrade. The bug this fixes, IPFS silently becoming memory storage, only happens when no real backend is configured, which is where the check sits.

Comment thread docs/api/headers.md
```bash
./fluree-db-server --cors-origin "*"
```
CORS is either on or off. It is on by default; disable it with `--cors-enabled=false`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 LOW-5 — headers.md keeps three headers the server doesn't implement

Same "found, not changed" bucket, and same argument: this is the file the finding is in, and you're editing it in this PR. I grepped the workspace for the three you named and confirmed it — X-Fluree-Fuel-Limit, X-Fluree-Timeout and X-Response-Time have zero hits in any .rs file, and X-Fluree-Timeout is also still in docs/troubleshooting/common-errors.md.

Given the PR is titled "docs for what exists", leaving three invented headers documented in the headers reference is the one place the thesis doesn't hold. The treatment you already applied to TLS, rate limiting and CORS allow-lists — say it doesn't exist, point at the reverse proxy where that fits — would drop straight in here. If the compression row needs more thought than a sentence, that half is a fair thing to separate; the three header names aren't.

eprintln!("{} config file: {e}", "warning:".yellow().bold());
}

// Nothing named a storage location: use the project's `.fluree/storage`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ INFO-6 — FLUREE_STORAGE_PATH starting to work is a behavior change worth a release note

Not asking for a code change — the new behavior is the documented one and the old one was the bug. But it seems worth calling out wherever release notes get written, because the failure mode is quiet: anyone who has FLUREE_STORAGE_PATH set in their environment today (left over, or set for the standalone fluree-server binary, or exported for a different tool) has been getting it ignored under fluree server run. After this, it wins, and the server comes up pointed at a different directory with no ledgers in it. Same for a profile's storage_path, which also could not take effect before.

The upgrade note more or less writes itself from your own precedence line: fluree server run now honors FLUREE_STORAGE_PATH and profile storage_path, which it previously overrode. If you have either set and did not expect it to apply, unset it before upgrading.


/// Enable CORS (Cross-Origin Resource Sharing)
#[arg(long, env = "FLUREE_CORS_ENABLED", default_value_t = server_defaults::DEFAULT_CORS_ENABLED)]
/// Enable CORS (Cross-Origin Resource Sharing). On by default;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ INFO-7 — the boolean fix is worth more than the body claims

Small correction for the description rather than the code. The body says "Clap's boolish parser keeps existing FLUREE_*=0-style env settings working" — I built a standalone clap 4.5.58 probe with the old and new arg definitions side by side, and the old definition didn't accept those at all. FLUREE_CORS_ENABLED=0, =off, =no, =1, and even =FALSE all came back ErrorKind::InvalidValue, i.e. the server refused to start. Only exactly true / false parsed.

So this isn't compatibility preservation, it's a second bug fixed: anyone who wrote FLUREE_INDEXING_ENABLED=0 in a compose file got a startup failure, and now gets what they meant. Worth saying out loud in the body, and arguably worth a line in the docs table at docs/operations/configuration.md:949 noting the accepted spellings.

`--help` said the cache budget defaults to 50% of RAM at 8GB and above;
the code and docs use 35%. The IPFS field IRI moves into `vocab` beside
the other storage fields, which also returns `parse_storage_node` its doc
comment.
The headers reference described request and response headers the server
never reads or sends: X-Fluree-Fuel-Limit, X-Fluree-Timeout,
X-Fluree-Policy, X-Fluree-T, X-Fluree-Commit, X-Response-Time, an echoed
X-Request-ID, ETag and Cache-Control on queries, and compression. It now
lists the fluree-* request headers and x-fdb-* tracking headers the server
does handle, and says which of the rest to get from a reverse proxy. The
query timeout is `FLUREE_QUERY_TIMEOUT_MS`, not a header, and the boolean
server switches list the spellings they accept.
@bplatz
bplatz merged commit a1530a8 into main Sep 28, 2026
9 checks passed
@bplatz
bplatz deleted the fix/server-config-docs branch September 28, 2026 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:cli fluree CLI UX, rdf toolkit, publish/export/insert flows area:server HTTP surface, routes, error mapping, swagger, timeouts/admission, config graph bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants