{"record":{"id":"a96270680839b15c","repo":"getredash/redash","slug":"username-and-password-required","errorCode":null,"errorMessage":"Username and Password required","messagePattern":"Username and Password required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"redash/query_runner/__init__.py","lineNumber":371,"sourceCode":"        }\n\n        if cls.requires_url or cls.requires_authentication:\n            schema[\"required\"] = []\n\n        if cls.requires_url:\n            schema[\"required\"] += [\"url\"]\n\n        if cls.requires_authentication:\n            schema[\"required\"] += [\"username\", \"password\"]\n        return schema\n\n    def get_auth(self):\n        username = self.configuration.get(\"username\")\n        password = self.configuration.get(\"password\")\n        if username and password:\n            return (username, password)\n        if self.requires_authentication:\n            raise ValueError(\"Username and Password required\")\n        else:\n            return None\n\n    def get_response(self, url, auth=None, http_method=\"get\", **kwargs):\n        # Get authentication values if not given\n        if auth is None:\n            auth = self.get_auth()\n\n        # Then call requests to get the response from the given endpoint\n        # URL optionally, with the additional requests parameters.\n        error = None\n        response = None\n        try:\n            response = requests_session.request(http_method, url, auth=auth, **kwargs)\n            # Raise a requests HTTP exception with the appropriate reason\n            # for 4xx and 5xx response status codes which is later caught\n            # and passed back.\n            response.raise_for_status()","sourceCodeStart":353,"sourceCodeEnd":389,"githubUrl":"https://github.com/getredash/redash/blob/ca79fe988d81cdac9675b412f3dfcab107bc1fbc/redash/query_runner/__init__.py#L353-L389","documentation":"BaseQueryRunner.get_auth raises ValueError when requires_authentication is True but the configuration lacks a truthy username or password. It is the Basic-auth precondition check run before any HTTP request by runners using get_response.","triggerScenarios":"Creating or using an HTTP/API-type query runner with requires_authentication=True while the configuration omits 'username' or 'password', or one of them is empty.","commonSituations":"Data source created via API/JSON without credentials, password cleared after rotation, or typo'd configuration key names.","solutions":["Open the data source settings and fill in both Username and Password","If the endpoint needs no auth, use a runner/configuration with requires_authentication=False","Verify configuration keys are exactly 'username' and 'password' when provisioning programmatically"],"exampleFix":"# before\nconfiguration = {\"url\": \"https://api.example.com\", \"username\": \"admin\"}\n\n# after\nconfiguration = {\"url\": \"https://api.example.com\", \"username\": \"admin\", \"password\": os.environ[\"API_PASSWORD\"]}","handlingStrategy":"validation","validationCode":"required = {'username', 'password'}\nif requires_authentication and not required.issubset({k for k, v in configuration.items() if v}):\n    raise SystemExit('set username & password before creating the data source')","typeGuard":"def has_basic_auth(config: dict) -> bool:\n    return bool(config.get('username')) and bool(config.get('password'))","tryCatchPattern":"try:\n    resp = runner.get_response(url)\nexcept ValueError as e:\n    if 'Username and Password required' in str(e):\n        fix_configuration(); retry","preventionTips":["Validate configuration completeness in provisioning scripts","Load secrets from env/vault so they never ship empty","Run test_connection right after creating the data source"],"tags":["redash","authentication","configuration","basic-auth"],"backgroundTag":"missing-credentials","analyzedSha":"ca79fe988d81cdac9675b412f3dfcab107bc1fbc","analyzedAt":"2026-08-28T18:32:34.637Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}