--- type: operations title: Configuration and data files description: How src/config.rs loads config.toml, the supported keys and defaults, where the data directory and databases live, and operational and security caveats. tags: [configuration, toml, data-directory, sqlite, security] verified: - by: openwiki/0.7.2 at: 2026-10-19T18:58:46.219Z sources: - id: openwiki-source-ea70eb6c045047448e446296 resource: repo://.gitignore - id: openwiki-source-2a737474d86fc75cc9d9694f resource: repo://src/config.rs generated: { by: "claude-code", at: "2026-10-19T18:58:46.219Z" } --- # Configuration and data files All runtime settings come from one TOML file loaded by `Config::load` (`src/config.rs:188-192`). No environment variable is ever read (`src/config.rs:1-13`). ## Data directory The data directory is fixed: `/wh`, resolved with `dirs::config_dir()` (`src/config.rs:106-110`). On Windows this is `%APPDATA%\wh`. It cannot be changed from the config file. At startup `ensure_data_dir` creates it if missing (`src/config.rs:214-217`). | File | Purpose | Defined by | |---|---|---| | `config.toml` | Optional settings | `CONFIG_FILE`, `src/config.rs:34` | | `session.db` | WhatsApp session store used by `whatsapp-rust` ([WhatsApp client](../integrations/whatsapp-client.md)) | `session_db_path`, `src/config.rs:223-225` | | `history.db` | Local messages, chats, contacts and autoreply flags ([History store](../concepts/history-store.md)) | `history_db_path`, `src/config.rs:231-233` | ## Keys | Key | Purpose | Default when missing or blank | |---|---|---| | `openai_api_key` | Bearer token for the AI endpoint (trimmed) | none — the [AI client](../integrations/ai-client.md) cannot be built | | `openai_base_url` | Base URL of the OpenAI-compatible endpoint (trimmed, trailing `/` removed) | `https://ollama.com/v1` | | `openai_model` | Model for text replies (trimmed) | `deepseek-v4.1-flash` | | `openai_vision_model` | Model for image replies (trimmed) | none — image understanding disabled | | `system_prompt` | Persona/instructions for autoreplies, kept as written (not trimmed, multiline allowed) | none — AI not configured | Mapping and defaults: `src/config.rs:198-208`, `src/config.rs:23-25`. The binary embeds no prompt text: without `system_prompt` the AI is not configured and the status line says so (see [Application state](../architecture/app-state.md)). Unknown keys are ignored. ## Loading rules - Missing file → all defaults (`src/config.rs:142-152`). - Unreadable file → `cannot read config file `. - Invalid TOML or wrong value type → `invalid config file ` with the cause `invalid TOML syntax or value type at line L, column C`; the error never echoes file content (`src/config.rs:127-136`). - A leading UTF-8 BOM (common with Windows editors) and CRLF line endings are tolerated. - `openai_base_url` consisting only of slashes is rejected with `openai_base_url in config.toml must not be empty or only slashes` (`src/config.rs:174-181`). Startup aborts with `cannot load configuration` on any of these errors ([Runtime](../architecture/runtime-and-event-loop.md)). ## Security and operational notes - The API key is never printed: `Config`'s `Debug` shows `***` or `` (`src/config.rs:80-100`), and the raw `FileConfig` has no `Debug` impl at all (`src/config.rs:64-78`). The AI client redacts it too. - Keep `config.toml` in the data directory, outside the repository. `.gitignore` ignores a root-level `/config.toml` and `.env` (`.gitignore:4-6`), as well as SQLite journal/WAL/SHM files; note that the `*.db` pattern is commented out (`.gitignore:7`), so databases copied into the repo would not be ignored. - `session.db` holds the linked-device credentials: deleting it forces a new QR pairing. `history.db` can be deleted to reset local history and autoreply flags; it is recreated on start. - Images downloaded for vision replies are kept in memory only and never written to the data directory. ## Tests `src/config.rs:236+` covers defaults, full files, blank values, multiline prompts, trimming, base URL normalisation and errors, `Debug` masking, vision model, DB paths, unknown keys, BOM/CRLF, non-leaking parse errors, missing, existing, invalid and unreadable files. See [Unit tests](../testing/unit-tests.md).