{"record":{"id":"c209919dc5bf4c2a","repo":"sigoden/aichat","slug":"miss","errorCode":null,"errorMessage":"Miss '{}'","messagePattern":"Miss '(.+?)'","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/client/macros.rs","lineNumber":235,"sourceCode":"                let request_data = $prepare_rerank(self, data)?;\n                let builder = self.request_builder(client, request_data);\n                $rerank(builder, self.model()).await\n            }\n        }\n    };\n}\n\n#[macro_export]\nmacro_rules! config_get_fn {\n    ($field_name:ident, $fn_name:ident) => {\n        fn $fn_name(&self) -> anyhow::Result<String> {\n            let env_prefix = Self::name(&self.config);\n            let env_name =\n                format!(\"{}_{}\", env_prefix, stringify!($field_name)).to_ascii_uppercase();\n            std::env::var(&env_name)\n                .ok()\n                .or_else(|| self.config.$field_name.clone())\n                .ok_or_else(|| anyhow::anyhow!(\"Miss '{}'\", stringify!($field_name)))\n        }\n    };\n}\n\n#[macro_export]\nmacro_rules! unsupported_model {\n    ($name:expr) => {\n        anyhow::bail!(\"Unsupported model '{}'\", $name)\n    };\n}\n","sourceCodeStart":217,"sourceCodeEnd":246,"githubUrl":"https://github.com/sigoden/aichat/blob/82976d349ad97ac9aae0655ad631dace5e2a6385/src/client/macros.rs#L217-L246","documentation":"A macro-generated config getter in src/client/macros.rs requires a value for a configuration field, looked up first from the environment variable `<CONFIG_NAME>_<FIELD>` (uppercased) and then from the config struct itself. When both are absent, it throws `Miss '<field>'`. This is the library's way of enforcing that every required client/config field is populated.","triggerScenarios":"Calling any accessor generated by this macro (e.g. getters for api_key, base_url, etc.) when neither the `{PREFIX}_{FIELD}` environment variable is set nor `self.config.$field_name` holds a value.","commonSituations":"Running the CLI without exporting the expected environment variable (e.g. OPENAI_API_KEY), having an empty string normalized away, or misspelling the env var name (wrong prefix, lowercase).","solutions":["Set the corresponding environment variable `<CONFIG_PREFIX>_<FIELD>` (e.g. `export OPENAI_API_KEY=sk-...`).","Add the field to the provider's config file / clients section so `self.config.$field_name` is populated.","Verify the env var name matches `{client-name}_{field}` uppercased with an underscore separator."],"exampleFix":"// before\n$ llm 'hello'\nError: Miss 'api_key'\n\n// after\nexport OPENAI_API_KEY=sk-...\n$ llm 'hello'","handlingStrategy":"validation","validationCode":"// Rust\nlet env_name = format!(\"{}_{}\", client_name, field).to_ascii_uppercase();\nif std::env::var(&env_name).is_err() && config_get_field(field).is_none() {\n    return Err(anyhow!(\"{} must be set via {} or config\", field, env_name));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Document required env vars per provider in your setup script/.env.","Use direnv or dotenv to load them automatically.","Validate all required config fields at startup before invoking the CLI."],"tags":["config","env","missing-value"],"backgroundTag":"missing-env-var","analyzedSha":"82976d349ad97ac9aae0655ad631dace5e2a6385","analyzedAt":"2026-09-09T18:33:06.139Z","contentChangedAt":"2026-09-09T18:33:06.139Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}