Skip to content

🗃️ Check for providers before creating the database - #43

Open
petterir wants to merge 2 commits into
mainfrom
fix/37-check-providers-before-db
Open

petterir wants to merge 2 commits into
mainfrom
fix/37-check-providers-before-db

Conversation

@petterir

Copy link
Copy Markdown
Collaborator

Fixes #37.

conduit proxy with no config, an empty conduit.toml, or a config without a [providers.*] section used to create conduit.db, -shm and -wal before failing on the missing providers. The providers check now runs right after the config loads, before the database is opened, so a config error leaves the directory as it was.

The error also says how to fix the problem and names the file that was read:

# no config file
Error: No providers configured: there is no config file at ./conduit.toml. Create one with a `[providers.<name>]` section (see conduit.example.toml), or use --config or CONDUIT_CONFIG to point elsewhere.

# a config file without providers
Error: No providers configured in other.toml. Add a `[providers.<name>]` section (see conduit.example.toml), or use --config or CONDUIT_CONFIG to point elsewhere.

Commits

  1. Check for providers before creating the database. Adds Config::ensure_providers(). main calls it for the proxy command before opening the database, and conduit_proxy::start calls it in place of its own check. The wording is unchanged in this commit. A new CLI test runs the binary in an empty temp directory and asserts nothing is created.
  2. Say how to fix a config without providers. Adds the new wording and what it needs to know where the config came from.

For the reviewer

  • Config gains a public source: ConfigSource field, skipped by serde so it can't be set from the TOML file. It is public because the proxy tests build Config { ..Config::default() } from another crate, and it takes part in ==.
  • dashboard still runs without providers; a test covers that.
  • The cli crate gets tempfile as a dev-dependency, hence the one-line Cargo.lock change.
  • The no-file message is built with Path::new(".").join(path), so it would read .\conduit.toml on Windows and the exact-string test would fail there. CI runs on Linux only.

Testing

cargo fmt --all --check, cargo clippy --workspace --tests --locked and cargo test --workspace --locked pass on each commit. The table from the issue was also reproduced by hand with the built binary: every config-error case exits 1 and leaves no database files, and a valid config still starts and creates the database.

🤖 Generated with Claude Code

Petteri Raatikainen and others added 2 commits November 19, 2026 12:29
`conduit proxy` with no config, an empty `conduit.toml`, or a config
without a `[providers.*]` section used to create `conduit.db`, `-shm`
and `-wal` before failing on the missing providers, because the
database was opened before `conduit_proxy::start` ran its check.

The check now lives in `Config::ensure_providers`, which `main` calls for
the proxy command right after loading the config, so a config error
leaves the working directory untouched. `start` calls the same method,
as it is a public entry point. The dashboard still runs without
providers. A CLI test runs the binary in an empty directory to keep it
that way.

Refs #37

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The "No providers specified" error didn't say which config Conduit read
or how to fix it. It now names the file that was read, or says that no
config file was found at ./conduit.toml, and suggests adding a
`[providers.<name>]` section or using --config / CONDUIT_CONFIG.

To know where the config came from, `Config` gets a `source` field set
by `Config::load`. It is skipped by serde, so it can't be set from the
TOML file, and defaults to `NotLoaded` for configs built in code.

Fixes #37

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the provider-validation startup changes.

No open issues 🎉

What changed in this PR

Fixes #37 by validating providers before proxy startup opens the database, preventing missing-provider errors from leaving database files behind.

Changes:

  • Shares provider validation between CLI and proxy startup while keeping dashboard usage provider-independent.
  • Tracks config provenance to provide actionable errors naming the selected or missing config file.
  • Adds CLI regression tests for rejected configs, filesystem side effects, and dashboard behavior.
File Description
crates/​proxy/​src/​lib.rs Uses shared provider validation at startup.
crates/​core/​src/​config.rs Adds config provenance, provider validation, diagnostics, and unit tests.
crates/​cli/​tests/​config_errors.rs Tests config errors, absence of created files, and dashboard behavior.
crates/​cli/​src/​main.rs Validates proxy providers before opening storage.
crates/​cli/​Cargo.toml Adds tempfile as a test dependency.
Cargo.lock Records the CLI’s tempfile dependency.

Review effort: Balanced

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.

conduit leaves conduit.db behind when it exits because no providers are configured

2 participants