Task: Implement Hotfix: Windows build fails on std::getenv deprecation
Table of Contents
This page documents a task in the Hotfix: Windows build fails on std::getenv deprecation story. It captures the goal, current status, acceptance, and any notes or results.
1. Goal
Replace every std::getenv call in test code that Windows compiles
with ores::testing::make_nats_options() – a shared helper in
ores.testing that reads the ORES_NATS_* variables through
ores::platform::environment::environment::get_value_or_default –
so the -Werror deprecation failure on Windows Clang goes away:
- the codegen template
ores.cpp.eventing-integration-test.nats_integration_test.org(tangled tocpp_nats_integration_test.cpp.mustache), which feeds ~85 generated*_eventing_integration_tests.cppfiles across ores.iam, ores.refdata, ores.reporting, and ores.trading; - the two hand-written ores.synthetic service tests
(
feed_config_handler_tests.cpp,folder_feed_control_handler_tests.cpp), which carry a copy of the sameenv()lambda.
systemd_notify.cpp already uses the ores.platform wrapper; no change.
2. Status
| Field | Value |
|---|---|
| State | DONE |
| Parent story | Hotfix: Windows build fails on std::getenv deprecation |
| Now | Nothing. |
| Waiting on | Nothing. |
| Next | Nothing. |
| Last touched | 2026-08-12 |
3. Acceptance
- No
std::getenvremains in any C++ source underprojects/(grep clean). - Generated test files are produced by the updated template: the template-drift check reports zero diff.
- The changed test targets build and pass on Linux; the fix is
portable by construction (the wrapper already guards Windows with
_putenv_s).
4. Plan
Root cause: MSVC's STL marks std::getenv deprecated in favour of
_dupenv_s, and Windows CI compiles with -Werror, so every file
that calls it fails the build (first observed in
account_type_eventing_integration_tests.cpp:60). The failing files
are codegen-generated from the
ores.cpp.eventing-integration-test.nats_integration_test archetype,
whose template inlines a per-file test_nats_options() helper (built
on std::getenv) into every generated test: 85 copies, plus two more
hand-written copies in ores.synthetic. The fix belongs in the
template, not in the generated files (CI enforces a zero-diff drift
check), and the duplicated helper is consolidated into one shared
helper rather than swapped file by file.
Steps:
- Add
ores::testing::make_nats_options(): a header-only helper in ores.testing (nats_options_helper.hpp) that reads theORES_NATS_*variables viaores::platform::environment::environment::get_value_or_defaultwith the same defaults the per-file helpers used. - Edit the org template: drop the inline
test_nats_options()block, include the helper header, callores::testing::make_nats_options()at the client construction site. - Re-tangle:
compass build --direct tangle_codegen_templates. - Regenerate per component with the codegen
(
--address ores.cpp.eventing-integration-test) and inspect the diff: every generated file should show only the include swap and the call-site change. - Replace the two ores.synthetic service tests' local
test_nats_options()with the shared helper. - Verify: grep for remaining
std::getenv, build the affected test targets, run the drift check.
5. Notes
- Review round 1 (2026-08-12): both claude[bot] reviews approve; one
non-blocking observation –
ORES_NATS_URLset-but-empty loses the localhost fallback withget_value_or_defaultalone. Fixed in 5995e8d3da: the helper now mirrors the original per-file lambda exactly (read with empty default, then fall back when empty).
6. Test Scenarios
Manual QA scenarios (scaffolded via compass add test_scenario, run
through the QA Validation Runner panel) that verify this task. Link
new ones here as they're created; the scenario doc itself links back
via its "Verifies task" field.
| Scenario | State | Notes |
|---|---|---|
7. PRs
8. Review
| # | Comment summary | File | Decision | Notes |
|---|---|---|---|---|
| 1 | ORES_NATS_URL set-but-empty loses the localhost fallback (both bot reviews otherwise approve) |
nats_options_helper.hpp | Fixed | 5995e8d3da restores the exact empty-string fallback |
9. Result
The std::getenv copies are gone: one shared
ores::testing::make_nats_options() (nats_options_helper.hpp,
header-only, reads the ORES_NATS_* variables through the
ores.platform environment provider with the original lambda's exact
semantics) replaces the 85 inlined helpers in the eventing-integration
template output and the 2 hand-written ores.synthetic copies. The
template and all 85 regenerated files across iam, refdata, reporting,
and trading-cpp changed only in the include swap and call site; the
template-drift check passed. Linux build and tests green:
ores.iam.core.tests (95s, incl. the 3 regenerated eventing tests)
and ores.synthetic.service.tests both pass. Remaining std::getenv
in the tree is only inside real_environment_provider.cpp itself.
Merged as PR #1981.