Story: Hotfix: Windows build fails on std::getenv deprecation
Table of Contents
This page documents a story in Sprint 25. It captures the goal, current status, acceptance criteria, and the tasks that compose it.
1. Goal
The Windows CI build fails on every test file that calls
std::getenv: Windows Clang compiles with
-Werror -Wdeprecated-declarations, and MSVC's STL deprecates
std::getenv in favour of _dupenv_s. The NATS eventing integration
tests (~85 generated files) and two hand-written ores.synthetic
service tests all call it. The fix replaces std::getenv with the
portable ores::platform::environment::environment wrapper in the
codegen template and regenerates, so the Windows build compiles again.
2. Status
| Field | Value |
|---|---|
| State | DONE |
| Parent sprint | Sprint 25 |
| Now | Nothing. |
| Waiting on | Nothing. |
| Next | Nothing. |
| Last touched | 2026-08-12 |
3. Acceptance
- The Windows CI build compiles every test target that previously
failed on the
std::getenvdeprecation warning. - The codegen template is the single source of the fix: regenerated test files match the template (zero-diff drift check).
- Test behaviour is unchanged: NATS connection options still resolve from the process environment the same way.
4. Tasks
| Task | State | Start | End | Description |
|---|---|---|---|---|
| Scaffold story: Hotfix: Windows build fails on std::getenv deprecation | DONE | 2026-08-12 | 2026-08-12 | Story scaffolding rides this task: documents, sprint wiring, and the scaffold PR. Close it before merging that PR. |
| Implement Hotfix: Windows build fails on std::getenv deprecation | DONE | 2026-08-12 | 2026-08-12 | Initial task for: Hotfix: Windows build fails on std::getenv deprecation |
5. Decisions
- Fix the codegen template and regenerate, rather than hand-editing the ~85 generated test files: the template is the single source and CI's drift check enforces it.
- Consolidate the duplicated
test_nats_options()helper (85 generated copies + 2 hand-written) into one sharedores::testing::make_nats_options()in ores.testing – header-only, likescoped_environment_override– rather than swappingstd::getenvforget_value_or_defaultin 87 copies. The helper reads theORES_NATS_*variables throughenvironment::get_value_or_defaultand keeps the exact empty-string semantics of theenv()lambda (the URL fallback tonats://localhost:4222depends on it). systemd_notify.cppalready usesores.platform::environment; no change needed there.
6. Out of scope
7. Result
Implemented and merged as PR #1981 (scaffold PR #1978 merged first).
The shared ores::testing::make_nats_options() helper replaces all 87
std::getenv-based test_nats_options() copies (85 codegen-generated
eventing integration tests + 2 hand-written ores.synthetic tests);
the only std::getenv left in the tree is inside
real_environment_provider.cpp itself. Template-drift check green;
Linux test suites pass.