{"record":{"id":"07eb4d9e84e144ca","repo":"assafelovic/gpt-researcher","slug":"retriever-endpoint-environment-variable-not-set","errorCode":null,"errorMessage":"RETRIEVER_ENDPOINT environment variable not set","messagePattern":"RETRIEVER_ENDPOINT environment variable not set","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"gpt_researcher/retrievers/custom/custom.py","lineNumber":18,"sourceCode":"from typing import Any, Dict, List\nimport requests\nimport os\n\n\nclass CustomRetriever:\n    \"\"\"\n    Custom API Retriever\n    \"\"\"\n\n    # The documented contract is list[{url, raw_content}] -- the caller's own\n    # endpoint supplies the content.\n    requires_scraping = False\n\n    def __init__(self, query: str, query_domains=None):\n        self.endpoint = os.getenv('RETRIEVER_ENDPOINT')\n        if not self.endpoint:\n            raise ValueError(\"RETRIEVER_ENDPOINT environment variable not set\")\n\n        self.params = self._populate_params()\n        self.query = query\n\n    def _populate_params(self) -> Dict[str, Any]:\n        \"\"\"\n        Populates parameters from environment variables prefixed with 'RETRIEVER_ARG_'\n        \"\"\"\n        return {\n            key[len('RETRIEVER_ARG_'):].lower(): value\n            for key, value in os.environ.items()\n            if key.startswith('RETRIEVER_ARG_')\n        }\n\n    def search(self, max_results: int = 5) -> List[Dict[str, Any]]:\n        \"\"\"\n        Performs the search using the custom retriever endpoint.\n","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/assafelovic/gpt-researcher/blob/6f998577d547b1e54ec662dac63583aa11e3b84b/gpt_researcher/retrievers/custom/custom.py#L1-L36","documentation":"ValueError raised by the custom retriever's __init__ when the RETRIEVER_ENDPOINT environment variable is unset/empty. The custom retriever delegates all fetching to an external HTTP endpoint, so without it there is nothing to query.","triggerScenarios":"Instantiating the custom retriever with os.getenv('RETRIEVER_ENDPOINT') returning None or \"\".","commonSituations":"Configuring retriever=\"custom\" without providing the endpoint var, .env not loaded, or a typo in the variable name in deployment configs.","solutions":["Set RETRIEVER_ENDPOINT to your retrieval service's URL (e.g. http://localhost:8000/retrieve).","Add it to .env and verify it's loaded before the retriever is created.","Double-check spelling (RETRIEVER_ENDPOINT, not RETRIEVER_URL) in compose/k8s files."],"exampleFix":"# before\nr = Custom(query=\"...\")  # raises ValueError\n\n# after\nimport os\nos.environ.setdefault(\"RETRIEVER_ENDPOINT\", \"http://localhost:8000/retrieve\")\nr = Custom(query=\"...\")","handlingStrategy":"validation","validationCode":"import os\nif not os.getenv(\"RETRIEVER_ENDPOINT\"):\n    raise SystemExit(\"Set RETRIEVER_ENDPOINT to your retrieval service URL\")","typeGuard":"null","tryCatchPattern":"try:\n    r = Custom(query)\nexcept ValueError as e:\n    if \"RETRIEVER_ENDPOINT\" in str(e):\n        raise SystemExit(str(e))\n    raise","preventionTips":["Set RETRIEVER_ENDPOINT in .env alongside other retriever config.","Health-check the endpoint URL at startup.","Use the exact variable name RETRIEVER_ENDPOINT."],"tags":["custom-retriever","missing-env-var","configuration"],"backgroundTag":"missing-env-var","analyzedSha":"6f998577d547b1e54ec662dac63583aa11e3b84b","analyzedAt":"2026-08-28T17:50:07.383Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}