{"record":{"id":"995d704b8d2c74f5","repo":"nautechsystems/nautilus_trader","slug":"tardis-machine-base-url-must-be-provided-or-set","errorCode":null,"errorMessage":"Tardis Machine `base_url` must be provided or set in the '{TARDIS_MACHINE_WS_URL}' environment variable","messagePattern":"Tardis Machine `base_url` must be provided or set in the '(.+?)' environment variable","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/tardis/src/common/urls.rs","lineNumber":33,"sourceCode":"\n//! Tardis base URL constants and environment-aware resolution.\n\nuse super::consts::TARDIS_MACHINE_WS_URL;\n\n/// Default Tardis REST API base URL.\npub const TARDIS_HTTP_BASE_URL: &str = \"https://api.tardis.dev/v1\";\n\n/// Resolves the Tardis Machine WebSocket base URL from an explicit value or the\n/// `TARDIS_MACHINE_WS_URL` environment variable.\n///\n/// # Errors\n///\n/// Returns an error if neither `url` nor the environment variable is set.\npub fn resolve_ws_base_url(url: Option<&str>) -> anyhow::Result<String> {\n    url.map(ToString::to_string)\n        .or_else(|| std::env::var(TARDIS_MACHINE_WS_URL).ok())\n        .ok_or_else(|| {\n            anyhow::anyhow!(\n                \"Tardis Machine `base_url` must be provided or \\\n                 set in the '{TARDIS_MACHINE_WS_URL}' environment variable\"\n            )\n        })\n}\n\n#[cfg(test)]\nmod tests {\n    use rstest::rstest;\n\n    use super::*;\n\n    #[rstest]\n    fn test_resolve_ws_base_url_with_explicit_value() {\n        let result = resolve_ws_base_url(Some(\"ws://localhost:8001\")).unwrap();\n        assert_eq!(result, \"ws://localhost:8001\");\n    }\n","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/tardis/src/common/urls.rs#L15-L51","documentation":"The Tardis adapter needs the Tardis Machine WebSocket URL to stream data. `resolve_ws_base_url` resolves it from the explicit `url` argument first, then from the `TARDIS_MACHINE_WS_URL` environment variable. If neither is present there is no connection target, so the library fails fast with this error instead of attempting a connection to an undefined host.","triggerScenarios":"Calling `connect` or `new` on the Tardis data client (or any path calling `resolve_ws_base_url`) without passing a `base_url`/`url` argument and without `TARDIS_MACHINE_WS_URL` set in the process environment.","commonSituations":"Running in a container or CI job where the env var was not forwarded; forgetting the config field when instantiating the client programmatically; a version change that removed a previously hardcoded default URL so an explicit value is now required.","solutions":["Pass the Tardis Machine URL explicitly, e.g. `resolve_ws_base_url(Some(\"ws://localhost:8000\"))` or set `base_url` in the client config.","Export the environment variable before running: `export TARDIS_MACHINE_WS_URL=ws://localhost:8000`.","If running under Docker/CI, ensure the env var is forwarded (e.g. `docker run -e TARDIS_MACHINE_WS_URL=...`).","Confirm a Tardis Machine instance is actually reachable at the URL you supply."],"exampleFix":"// before\nlet url = resolve_ws_base_url(None)?;\n// after\nlet url = resolve_ws_base_url(Some(\"ws://localhost:8000\"))?;\n// or: export TARDIS_MACHINE_WS_URL=ws://localhost:8000 before running","handlingStrategy":"validation","validationCode":"import os\n\ndef ensure_tardis_url(base_url: str | None) -> str:\n    url = base_url or os.environ.get(\"TARDIS_MACHINE_WS_URL\")\n    if not url:\n        raise ValueError(\"Tardis Machine URL must be provided or TARDIS_MACHINE_WS_URL set\")\n    return url","typeGuard":"def has_tardis_url(base_url: str | None) -> bool:\n    return bool(base_url or os.environ.get(\"TARDIS_MACHINE_WS_URL\"))","tryCatchPattern":null,"preventionTips":["Set TARDIS_MACHINE_WS_URL in your .env / deployment manifest for every environment","Resolve the URL at startup and fail fast before any long-running work","Document the required env var in the service README and CI config"],"tags":["rust","configuration","network","env-var"],"backgroundTag":"missing-env-var","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}