Skip to content

DAQ backend tests: stop writing profiles into the checkout's config/ - #222

Open
cytocracy wants to merge 1 commit into
mainfrom
fix/daq-backend-config-path-leak
Open

cytocracy wants to merge 1 commit into
mainfrom
fix/daq-backend-config-path-leak

Conversation

@cytocracy

@cytocracy cytocracy commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Running the DAQ backend's npm test on a machine with a deployed daq-server/config/config.toml writes into the checkout: config/profiles/cold_flow/ and config/profiles/taken/ appear. From the second run on, config-profile-create-calibration.test.ts fails with Profile "cold_flow" already exists. This leak has now turned up twice.

Cause

The tests set CONFIG_PATH to a config.toml in a temp dir that they haven't written yet. When CONFIG_PATH named a missing file, getConfigPath() fell back to cwd/../../config/config.toml, which is the developer's real config, and the profile-creation handlers wrote next to it. A fresh clone has no generated config.toml, so the tests passed there and CI never saw the problem.

Fix

When CONFIG_PATH is set, it's the only path getConfigPath() tries. If the file doesn't exist yet, the existing self-heal generates it from the profiles in the same folder. When CONFIG_PATH is unset, the lookup is unchanged.

Nothing that runs the real stand changes:

  • Production never sets CONFIG_PATH; sensor-backend.service and start_systemd_sim.sh say so explicitly.
  • test_integration.sh and replay_past_db.sh both write their config file before starting the backend.

Test

config-path-explicit.test.ts puts a decoy config.toml where the fallback looks and points CONFIG_PATH at a missing file that has a profile next to it. The test fails on the old code (it returns the decoy) and passes with the fix.

With a real config/config.toml present, the full backend suite gives 357 passed and 1 failed, and nothing is written to config/profiles/. The failure is video.test.ts "on macOS is the Bonjour name", which also fails on main and is unrelated.

Merges cleanly with #223 (which moves this file to star_server/; git follows the rename).

getConfigPath() fell back to the checkout's config/config.toml whenever
CONFIG_PATH named a file not yet written. Backend tests point CONFIG_PATH at a
fresh temp dir, so on any machine with a deployed config they read the real
one and created profiles beside it: config/profiles/cold_flow/ and taken/
appeared in the checkout after npm test, and the calibration-profile tests
failed on 'already exists' from the second run on.

With CONFIG_PATH set, it is now the only candidate; the existing self-heal
generates it from the profiles beside it. Unset, the lookup is unchanged.
Production never sets CONFIG_PATH (the deploy scripts say so); the
integration harness and replay_past_db.sh write their file first.

config-path-explicit.test.ts puts a decoy where the fallback looks and fails
on the old code.

This branch has not been deployed

No deployments
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.

1 participant