Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
84a291c
settings: the URL check's docstring names an ASCII scheme, judged aft…
wshallwshall Dec 1, 2026
4c62e43
docs: CONFIGURATION.md's backup and DR path rows state the URL check'…
wshallwshall Dec 1, 2026
7578fe5
tests: pin the anchor check's refusal of a PEM block with no data, in…
wshallwshall Dec 1, 2026
a7a5379
dr_backup: the config walk adds each file from a handle opened throug…
wshallwshall Dec 1, 2026
12fa88b
docs: the include_config row says what a link swap still reaches in t…
wshallwshall Dec 1, 2026
96cd0fe
dr_backup: a config file the walk accepted fails or is added by name …
wshallwshall Dec 1, 2026
1608d20
docs: the include_config row states one rule for a config file the wa…
wshallwshall Dec 1, 2026
5066161
dr_backup: a config file whose Windows final path cannot be read is a…
wshallwshall Dec 1, 2026
a375420
dr_backup: the config walk's reader closes a descriptor once, and the…
wshallwshall Dec 1, 2026
1eebfa0
docs: the include_config row says a file whose final path Windows can…
wshallwshall Dec 1, 2026
3469af8
dr_backup: a read or write that fails on a config file's handle names…
wshallwshall Dec 1, 2026
a9dbd4d
docs: the include_config row places the ancestor residual by platform…
wshallwshall Dec 1, 2026
df7a6a7
dr_backup: the config walk re-checks held folders after the open (BAC…
wshallwshall Dec 1, 2026
58fd4ff
docs: the include_config row names the re-check and its residuals (BA…
wshallwshall Dec 1, 2026
bc63960
dr_backup: a root hold the volume does not support asks the volume (B…
wshallwshall Dec 2, 2026
16a28c0
docs: the include_config row names the root hold and each remedy (BAC…
wshallwshall Dec 2, 2026
d83236b
dr_backup: a name swapped for a folder before the open by name is pas…
wshallwshall Dec 2, 2026
214ff76
docs: the include_config row says the three codes are a reading, not …
wshallwshall Dec 2, 2026
6f7b00c
dr_backup: the open by name passes over a descriptor that reached a f…
wshallwshall Dec 2, 2026
d3c8ff3
file: the confined open's docstring gives its re-check residuals as a…
wshallwshall Dec 2, 2026
34d775c
dr_backup: a final path a volume with no drive letter cannot give nam…
wshallwshall Dec 2, 2026
a4b7ed7
dr_backup: a root hold the volume refuses names the config dir, after…
wshallwshall Dec 2, 2026
dd9f38e
dr_backup: a config refusal puts its cause and remedy before the name…
wshallwshall Dec 2, 2026
b2d7103
docs: the include_config row names the order of each refusal's text (…
wshallwshall Dec 2, 2026
89b3861
dr_backup: repair round 1 on the config refusals (BACKLOG #6573)
wshallwshall Dec 2, 2026
7ec73d8
docs: the include_config row gives the final-path remedy as a conditi…
wshallwshall Dec 2, 2026
0fc8356
dr_backup: repair round 2 on the config refusals (BACKLOG #6573)
wshallwshall Dec 2, 2026
8ac775b
docs: the include_config row screens a name only after a hold refused…
wshallwshall Dec 2, 2026
da0571f
tests: the length test builds Windows' own text where mypy can see th…
wshallwshall Dec 2, 2026
f58c78a
store: every backend refuses reference keys some backend cannot hold …
wshallwshall Dec 1, 2026
20b3e3d
docs: reference-set key rules on every backend, and the SetState surr…
wshallwshall Dec 1, 2026
64e91a9
reference keys: review round 1 fixes, preview and rename keep the rul…
wshallwshall Dec 1, 2026
f0a7edf
docs: reference-set key rules after review round 1 (BACKLOG #6613)
wshallwshall Dec 1, 2026
77fa5a3
reference keys: review round 2 fixes (BACKLOG #6613)
wshallwshall Dec 1, 2026
20a74d0
docs: reference-set key rules after review round 2 (BACKLOG #6613)
wshallwshall Dec 1, 2026
156a1f5
vault: both hops take the unset-token refusal from one builder (BACKL…
wshallwshall Dec 1, 2026
2e79b92
vault: comments name where each unset refusal's text now lives (BACKL…
wshallwshall Dec 1, 2026
5fe9a65
engine_secrets: the token refusal's docstring says when serviceenv re…
wshallwshall Dec 2, 2026
4bc7b07
engine_secrets: name the wrapper gap and the unset directory (BACKLOG…
wshallwshall Dec 2, 2026
56c9fb8
engine_secrets: point at serviceenv instead of copying its coverage (…
wshallwshall Dec 2, 2026
a7a4338
serviceenv: the docstrings say what a failed walk and a failed machin…
wshallwshall Dec 2, 2026
a95af89
Rename the NUL-key test's store file off a Windows reserved device na…
wshallwshall Dec 2, 2026
746bb5c
Name the Windows release that opens NUL.<ext> as the device (BACKLOG …
wshallwshall Dec 2, 2026
1791052
Merge remote-tracking branch 'origin/b20053-6613b' into b20053-4800d
wshallwshall Dec 2, 2026
487a8c6
Merge branch 'main' into b20053-6573e
wshallwshall Dec 2, 2026
696839a
Config backup: an unreachable share at the first screen fails the bac…
wshallwshall Dec 2, 2026
de6f637
Config backup: the held-dir remedy is a sharing violation's only, giv…
wshallwshall Dec 2, 2026
91580d2
Config backup docs: a stat failure on an unreachable share is no long…
wshallwshall Dec 2, 2026
3e75f94
docs: include_config row names the two unreachable codes and the unre…
wshallwshall Dec 2, 2026
edb52ab
Merge commit '3e75f941363152edc378c2983c19eb5173dd5aa0' into repair-3…
wshallwshall Dec 2, 2026
8a2967d
Merge remote-tracking branch 'origin/main' into repair-3541-m1
wshallwshall Dec 2, 2026
2280c03
Reference key refusals name the remedy, and any CipherError names a f…
wshallwshall Dec 3, 2026
fc69c72
Reference key remedies keep lookups working, and the state cache docs…
wshallwshall Dec 3, 2026
268266f
Merge branch 'b20053-6613b' into b20053-4800c
wshallwshall Dec 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.d/6613-setstate-entry-correction.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- **Correction to the 0.5.3 entry on `SetState` key refusals.** It said each refusal names the
field and its length. Each names the field and the rule, never the value; only a refusal for
length also gives the length in UTF-16 code units. (`BACKLOG #6613`)
17 changes: 17 additions & 0 deletions changelog.d/6613.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- **Every store backend refuses a reference snapshot holding two keys that differ only by trailing
spaces, or a key holding NUL or a surrogate; a set name ending in a space or holding NUL or a
surrogate is refused at load and at rename.** These rules still accept a lone key with a trailing
space and an over-long key; SQL Server's key and name widths stay its own check. SQLite and
Postgres now refuse, before the snapshot's transaction, two keys that differ only by trailing
spaces, as SQL Server already did, and every backend refuses a key holding U+0000 (NUL), which
Postgres text cannot store, or a surrogate code point, which no backend stores. Each of
these key refusals is a `ReferenceSnapshotRefused` (the collision is its subclass
`ReferenceKeyCollision`), naming the set, the keys by 0-based ordinal and the remedy, never a key, and logged whole; the last-good
snapshot stays active and the sync fails every interval until the source changes. A dry run and
`check` skip such a file-backed set with a warning naming the same set, rule and ordinals. A
`Reference(...)` name that ends in a space or holds U+0000 or a surrogate is refused at load on
every backend, and so is a rename to such a name, since SQL Server compares `npi` and `npi ` as
one name. A SQL Server open now also reports a non-binary collation on the `reference` and
`reference_version` key columns, at WARNING, and repairs nothing.
`SetState`'s refusal of a surrogate code point now says so rather than "lone surrogate", since
half of a pair is refused too, and `StateKeyError` is exported from `messagefoundry`. (`BACKLOG #6613`)
27 changes: 24 additions & 3 deletions docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -708,19 +708,21 @@ def anonymize(msg):
is an **upsert by `(namespace, key)`** the engine applies **inside the routed→outbound handoff
transaction**. `Send`-only Handlers are unchanged — fully **backward compatible**.
- **Keys are exact, and bounded.** `namespace` and `key` must be non-empty strings that do not end
in a space (U+0020) and contain no NUL (U+0000) and no lone surrogate (U+D800 to U+DFFF). Each is
in a space (U+0020) and contain no NUL (U+0000) and no surrogate code point (U+D800 to U+DFFF),
whether lone or half of a pair held as two code points. Each is
at most 256 UTF-16 code units, and the two together at most 450. `SetState(...)` raises
`StateKeyError` (a `WiringError`) at construction otherwise, on every store backend, and the error
names the field, never its value. Why: SQL Server ignores trailing spaces when it compares keys,
so `k` and `k ` would otherwise be one stored row there and two everywhere else; Postgres text
cannot hold NUL; no backend stores a lone surrogate; and SQL Server's `state` columns are
cannot hold NUL; no backend stores a surrogate code point; and SQL Server's `state` columns are
`NVARCHAR(256)` under a clustered primary key capped at 900 bytes. A field read from a fixed-width
sender can carry padding: strip it before keying on it, for example
`(msg["PID-3.1"] or "").rstrip(" ")`. Case and accents are compared exactly on SQLite, on
Postgres, and on a SQL Server database whose `state` table this release or a later one created. A
SQL Server `state` table created earlier keeps the database's default collation, which may fold
case (BACKLOG #1588); the engine logs a WARNING at every open of a table whose key columns are not
binary, naming the collation and the remedy, and repairs nothing (BACKLOG #4917).
binary, naming the collation and the remedy, and repairs nothing (BACKLOG #4917). The
warning itself does not stop the open.
- **Exactly-once / re-run safety.** Because the write commits in the **same transaction** as the
outbound rows, a crash before commit leaves **no** state (atomic with the handoff) and the attempt
that commits applies the write **exactly once per message** — this preserves the staged pipeline's
Expand Down Expand Up @@ -811,6 +813,25 @@ crash-re-run — the same accepted caveat as a code-set hot-reload).
seconds, default `30`, `0` = no limit) bounds each call, the execute and each fetch, and a result
that does not fit its columns, at least a missing or doubled column, a NULL key or a duplicate key, fails the sync rather than replacing the last-good snapshot; see
[`CONNECTIONS.md`](CONNECTIONS.md) §*A `DatabaseRef` statement passes the same gate, and a row ceiling*.
- **Keys and set names are exact.** Every store backend refuses a snapshot holding two keys that
differ only by trailing spaces (U+0020), which SQL Server compares as equal, a key holding NUL
(U+0000), which Postgres text cannot store, or a key holding a surrogate code point (U+D800 to
U+DFFF), which no backend stores, before the snapshot's transaction (BACKLOG #4917, #6613). The
sync then fails and alerts every interval until the source changes, and the last-good snapshot
stays active. The log line names the set and the keys by 0-based ordinal, their position among
the keys the source yielded, never a key; an ordinal is not a file line number. The line also
names the remedy, at the source: for two keys that differ only by trailing spaces, remove one of
the two and strip the spaces from the one kept; for NUL or a lone surrogate, strip it or remove
that key; for a surrogate pair, write it as its one character or remove that key. Keep only one of
any two keys that leaves equal. A lone key with a trailing space is not refused. A dry run and
`messagefoundry check` skip such a file-backed set, with a warning naming the same
set, rule and ordinals, since the next sync refuses it; an engine that synced the set before keeps serving its last-good snapshot meanwhile. A
`Reference(...)` name that ends in a space or holds NUL or a surrogate code point is refused at
load, on every backend, and so is a rename to such a name. SQL Server compares `npi` and `npi `
as one name, so a set renamed from one to the other across a reload would share the old set's
stored rows there. SQL Server also bounds a key at 450 UTF-16 code units and a set name at 256,
and reports a non-binary collation on the `reference` and `reference_version` key columns at
open, at WARNING, repairing nothing.
- **Sync.** The engine's `ReferenceSyncRunner` materializes each set once at startup (before listeners
serve, so `reference(...)` resolves on the first message) and every `refresh_seconds`. A source
failure is **isolated**: it's logged + alerted and the **last-good snapshot is kept** (the write
Expand Down
7 changes: 7 additions & 0 deletions docs/adr/0006-external-data-lookups.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,13 @@ first-ever reference-row key-rotation tests on all three backends.
Server `write_reference_snapshot` now refuses such a snapshot before its transaction with
`ReferenceKeyCollision`, naming the two keys by ordinal only. The sync still fails and alerts
every interval, and the last-good snapshot stays active, as it did when the INSERT failed.
**AMENDED 2026-12-01 (BACKLOG #6613):** the refusal moved to
`store/reference_keys.py`, which SQLite and Postgres call too, so a set breaking that rule
fails the same way on every backend; the column widths above stay SQL Server's own. It also
refuses a key holding U+0000, which Postgres text cannot store, or a surrogate code point, which
no backend stores, as a `ReferenceSnapshotRefused`, the collision's base class. A set name that
ends in a space or holds either is refused at load. A SQL Server open warns, repairing nothing,
when the `reference` or `reference_version` key columns are not binary.
- **Encryption at rest.** Values are `cipher.encrypt(json.dumps(v))` (`mfenc`), covered by **both**
`reencrypt_to_active` (key rotation) **and** `_encrypt_existing_rows` (the no-key→key migration
pass). The migration pass is required because "born encrypted" is false: under a no-key deployment
Expand Down
3 changes: 3 additions & 0 deletions messagefoundry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
SetState,
Sftp,
Soap,
StateKeyError,
Tcp,
Timer,
code_set,
Expand Down Expand Up @@ -185,6 +186,7 @@
"Send": "messagefoundry.config.wiring",
"SetMeta": "messagefoundry.config.wiring",
"SetState": "messagefoundry.config.wiring",
"StateKeyError": "messagefoundry.config.wiring",
"Sftp": "messagefoundry.config.wiring",
"Soap": "messagefoundry.config.wiring",
"Tcp": "messagefoundry.config.wiring",
Expand Down Expand Up @@ -263,6 +265,7 @@ def __dir__() -> list[str]:
"split_by_obr",
"Send",
"SetState",
"StateKeyError",
"SetMeta",
"state_get",
"response_get",
Expand Down
6 changes: 6 additions & 0 deletions messagefoundry/config/impact.py
Original file line number Diff line number Diff line change
Expand Up @@ -3334,6 +3334,12 @@ def _validate_new_name(config_dir: Path, target_kind: str, new: str) -> None:
f"the new name {new!r} is not a valid connection name: it must match "
f"{CONNECTION_NAME_PATTERN}"
)
# A renamed reference set must still load: Registry.add_reference refuses a set name ending in a
# space (BACKLOG #6613). U+0000 is a control character, refused above.
if target_kind == "reference" and new.endswith(" "):
raise WiringError(
f"the new name {new!r} is not a valid set name: it must not end with a space"
)
if target_kind in _FILE_BACKED_KINDS:
# Reuse the exact traversal/drive/containment rules the codeset writer enforces on a file stem.
from messagefoundry.config.code_sets import CODESETS_DIR_NAME
Expand Down
34 changes: 12 additions & 22 deletions messagefoundry/config/secretprovider_vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

import logging
import os
import sys
from collections.abc import Iterable
from typing import TYPE_CHECKING, Any

Expand All @@ -41,7 +40,11 @@
vault_client_verify_kwargs,
vault_hop_refusal_text,
)
from messagefoundry.engine_secrets import SecretsDirectoryError, secret_setting
from messagefoundry.engine_secrets import (
SecretsDirectoryError,
secret_setting,
vault_token_unset,
)

if TYPE_CHECKING:
from messagefoundry.config.settings import SecretsSettings
Expand All @@ -62,7 +65,8 @@
#
# BACKLOG #2851: both are REQUIRED and always handed to hvac. Given None, hvac reads VAULT_ADDR,
# VAULT_TOKEN and then ~/.vault-token, which in an operator's shell are the operator's own Vault and
# token. So an unset or empty variable refuses, with the fixed text below, rather than fall back.
# token. So an unset or empty variable refuses, with fixed text (the address's below, the
# token's from engine_secrets.vault_token_unset), rather than fall back.
# The twin of store/keyprovider_vault.py's.
_ENV_ADDR = "MEFOR_SECRETS_VAULT_ADDR"
_ENV_TOKEN = "MEFOR_SECRETS_VAULT_TOKEN" # nosec B105 — the env-var NAME, not a token value
Expand All @@ -76,33 +80,19 @@
#: not reach this hop yet.)
_ENV_CA_FILE = "MEFOR_SECRETS_VAULT_CA_FILE"

#: The refusals for an unset address or token: fixed text naming the variable, never a value. One
#: text each, for the provider and ``check-privileges`` alike (BACKLOG #2851).
#: The refusal for an unset address: fixed text naming the variable, never a value, for the
#: provider and ``check-privileges`` alike (BACKLOG #2851). The token's is :func:`_token_unset`.
_ADDR_UNSET = (
f"{_ENV_ADDR} is not set or is empty, so the connector-secret Vault is not known. The engine "
f"sends its token only to the address named there, never to VAULT_ADDR. Set it in the "
f"service's environment, and run check-privileges with that environment"
)
_TOKEN_UNSET = (
f"{_ENV_TOKEN} is not set or is empty, in the secrets directory or the environment, so the "
f"connector-secret token is not known. The engine reads only the token named there, never "
f"VAULT_TOKEN or ~/.vault-token. Supply it to the service in one of those two places, and "
f"run check-privileges with the service's environment"
)
#: The Windows twin, as in ``store/keyprovider_vault.py``: on Windows the token goes in the
#: secrets directory only, never in the service's environment (owner ruling 2026-10-01).
_TOKEN_UNSET_WINDOWS = (
f"{_ENV_TOKEN} is not set or is empty, so the connector-secret token is not known. On "
f"Windows, supply it only as the file named {_ENV_TOKEN} in the secrets directory "
f"MEFOR_SECRETS_DIRECTORY names, never in the service's environment. The engine never reads "
f"VAULT_TOKEN or ~/.vault-token in its place. Run check-privileges with "
f"MEFOR_SECRETS_DIRECTORY set as the service has it"
)


def _token_unset(platform: str | None = None) -> str:
"""The unset-token refusal for ``platform``, this process's when ``None``. Fixed text."""
return _TOKEN_UNSET_WINDOWS if (platform or sys.platform) == "win32" else _TOKEN_UNSET
"""The unset-token refusal for ``platform``, this process's when ``None``. Fixed text, from
the builder both Vault hops share (BACKLOG #4800)."""
return vault_token_unset(_ENV_TOKEN, "connector-secret token", platform)


#: Default field read from a KV secret when a reference omits ``#<field>``.
Expand Down
41 changes: 34 additions & 7 deletions messagefoundry/config/wiring.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ def handle(msg):
is_connection_name,
reference_record_name,
)
from messagefoundry.controlchars import scrub_control_chars, scrub_log_argument
from messagefoundry.controlchars import (
has_lone_surrogate,
scrub_control_chars,
scrub_log_argument,
)
from messagefoundry.credential import QUALIFIED_CERT_NAME, unmatchable_san_reason
from messagefoundry.exception_origin import (
exception_chain,
Expand Down Expand Up @@ -6029,8 +6033,9 @@ def __post_init__(self) -> None:
if "\x00" in text:
raise StateKeyError(f"SetState {name} must not contain U+0000 (NUL)")
# NVARCHAR counts UTF-16 code units. ASCII is one unit per char, so the usual MRN-style
# key skips the encode. A strict encode refuses a lone surrogate (U+D800..U+DFFF): no
# backend stores one, and the backend's bind would raise it inside the handoff, a
# key skips the encode. A strict encode refuses any surrogate code point (U+D800..U+DFFF),
# a lone one or half of a pair held as two code points: no backend stores either, and
# the backend's bind would raise it inside the handoff, a
# store error the runner retries rather than a content fault it dead-letters. A key
# already over the limit in code points is refused unencoded: each is at least a unit,
# so a huge content-derived key costs no copy.
Expand All @@ -6040,16 +6045,17 @@ def __post_init__(self) -> None:
elif len(text) > STATE_KEY_MAX_UNITS:
field_units, at_least = len(text), "at least "
else:
lone_surrogate = False
surrogate = False
try:
field_units = len(text.encode("utf-16-le")) // 2
except UnicodeEncodeError:
# Raised outside the handler: the encode error's `.object` is the whole key, so
# it must not ride the chain as __context__ (nor would `from None` stop that).
lone_surrogate = True
if lone_surrogate:
surrogate = True
if surrogate:
raise StateKeyError(
f"SetState {name} must not contain a lone surrogate (U+D800..U+DFFF)"
f"SetState {name} must not contain a surrogate code point (U+D800..U+DFFF);"
" write a character beyond U+FFFF as one code point"
)
if field_units > STATE_KEY_MAX_UNITS:
raise StateKeyError(
Expand Down Expand Up @@ -7620,6 +7626,27 @@ def add_handler(self, name: str, fn: HandlerFn, accepts: HandlerAccepts | None =
self.handler_accepts[name] = accepts

def add_reference(self, spec: ReferenceSpec) -> None:
# BACKLOG #6613: SQL Server pads a trailing space when it compares a set name (the `state`
# comment in store/sqlserver.py's _SCHEMA says why), so a set renamed from `npi` to `npi `
# across a reload would share the old set's stored rows there, where SQLite and Postgres
# keep them apart. This refusal comes first, so case_twins' trailing-space fold no longer
# sees a reference set name. Postgres text cannot hold U+0000, and no backend stores a
# surrogate code point. Refused on every backend, as SetState refuses such a key. A name
# that is not a string is left to graph_problems, as before.
if isinstance(spec.name, str):
if spec.name.endswith(" "):
raise WiringError(
f"reference set {spec.name!r}: a set name must not end with a space"
)
if "\x00" in spec.name:
raise WiringError(
f"reference set {spec.name!r}: a set name must not contain U+0000 (NUL)"
)
if has_lone_surrogate(spec.name):
raise WiringError(
f"reference set {spec.name!r}: a set name must not contain a surrogate code"
" point (U+D800..U+DFFF)"
)
self._add(self.references, spec.name, spec, "reference set")

def add_lookup(self, spec: DatabaseLookupSpec) -> None:
Expand Down
33 changes: 31 additions & 2 deletions messagefoundry/engine_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
neither file.

**What this slice does not do**, at least: refuse a secret found in the environment (slice B
later made the NSSM reading in :mod:`messagefoundry.serviceenv` refuse one in the service's own
lists, where it could read them);
later made the NSSM reading in :mod:`messagefoundry.serviceenv` refuse some, as that module
says);
create the directory (the Windows service installer does, slice C, and names it to the service);
wrap a file with DPAPI (a plain file restricted by
its access list is the control, and whether a Windows file is also wrapped waits on a spike); and
Expand Down Expand Up @@ -72,6 +72,7 @@
"open_secrets_directory",
"secret_setting",
"secret_settings",
"vault_token_unset",
]

#: The variable that names the secrets directory. A path, not a secret.
Expand Down Expand Up @@ -631,6 +632,34 @@ def secret_settings(
return found


def vault_token_unset(variable: str, subject: str, platform: str | None = None) -> str:
"""The refusal for a Vault token ``variable`` that is unset or empty, naming what it is the
token of as ``subject``, for ``platform``, this process's when ``None``. Fixed text, never a
value. Both Vault hops build their unset-token refusal here (BACKLOG #2851, #4800); each
keeps its own unset-address text.

On Windows the token is to go in the secrets directory only, never in the service's environment
(owner ruling 2026-10-01), so that text never points a Windows operator at the environment.
:mod:`messagefoundry.serviceenv` says where a token in the environment refuses the start and
what it misses. :func:`secret_settings` still reads the environment's token when the secrets
directory is unset or holds no file for it; refusing that on Windows is one limb of vault
BACKLOG #4800 item 1."""
if (platform or sys.platform) == "win32":
return (
f"{variable} is not set or is empty, so the {subject} is not known. On Windows, supply "
f"it only as the file named {variable} in the secrets directory "
f"{SECRETS_DIRECTORY_VARIABLE} names, never in the service's environment. The engine "
f"never reads VAULT_TOKEN or ~/.vault-token in its place. Run check-privileges with "
f"{SECRETS_DIRECTORY_VARIABLE} set as the service has it"
)
return (
f"{variable} is not set or is empty, in the secrets directory or the environment, so the "
f"{subject} is not known. The engine reads only the token named there, never VAULT_TOKEN "
f"or ~/.vault-token. Supply it to the service in one of those two places, and run "
f"check-privileges with the service's environment"
)


def secret_setting(name: str, *, environ: Mapping[str, str] | None = None) -> str | None:
"""The value of one secret-class setting, as :func:`secret_settings` reads it."""
return secret_settings((name,), environ=environ)[name]
Loading
Loading