{"record":{"id":"b01afcc72103afd7","repo":"getredash/redash","slug":"failed-getting-schema-b01afc","errorCode":null,"errorMessage":"Failed getting schema","messagePattern":"Failed getting schema","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"redash/query_runner/treasuredata.py","lineNumber":90,"sourceCode":"    def type(cls):\n        return \"treasuredata\"\n\n    def get_schema(self, get_stats=False):\n        schema = {}\n        if self.configuration.get(\"get_schema\", False):\n            try:\n                with tdclient.Client(\n                    self.configuration.get(\"apikey\"), endpoint=self.configuration.get(\"endpoint\")\n                ) as client:\n                    for table in client.tables(self.configuration.get(\"db\")):\n                        table_name = \"{}.{}\".format(self.configuration.get(\"db\"), table.name)\n                        for table_schema in table.schema:\n                            schema[table_name] = {\n                                \"name\": table_name,\n                                \"columns\": [column[0] for column in table.schema],\n                            }\n            except Exception:\n                raise Exception(\"Failed getting schema\")\n        return list(schema.values())\n\n    def run_query(self, query, user):\n        connection = tdclient.connect(\n            endpoint=self.configuration.get(\"endpoint\", \"https://api.treasuredata.com\"),\n            apikey=self.configuration.get(\"apikey\"),\n            type=self.configuration.get(\"type\", \"hive\").lower(),\n            db=self.configuration.get(\"db\"),\n        )\n\n        cursor = connection.cursor()\n        try:\n            cursor.execute(query)\n            columns_tuples = [\n                (i[0], TD_TYPES_MAPPING.get(i[1], None)) for i in cursor.show_job()[\"hive_result_schema\"]\n            ]\n            columns = self.fetch_columns(columns_tuples)\n","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/getredash/redash/blob/ca79fe988d81cdac9675b412f3dfcab107bc1fbc/redash/query_runner/treasuredata.py#L72-L108","documentation":"Raised by TreasureData.get_schema (redash/query_runner/treasuredata.py:90) as a bare re-raise when any exception occurs while listing databases/tables via the tdclient API during schema generation. The original exception is swallowed, so the message gives no root cause — typical causes are an invalid/expired API key, wrong endpoint, or network failure to api.treasuredata.com.","triggerScenarios":"Opening or refreshing the schema browser for a Treasure Data data source whose apikey is rejected, whose endpoint is misconfigured, or when the TD API is unreachable; any error inside the list_databases/list_tables iteration triggers this.","commonSituations":"Rotated or revoked TD API keys after the data source was configured; typo'd custom endpoint; outbound firewall blocking api.treasuredata.com; tdclient version incompatibility raising inside the loop.","solutions":["Validate the apikey independently: `curl -H 'Authorization: TD1 <key>' https://api.treasuredata.com/v3/databases`","Fix or re-paste the API key in the data source settings and run Test Connection","Confirm the endpoint URL and network egress from the Redash worker to api.treasuredata.com","Patch locally to log the original exception (raise ... from exc) so future failures name the root cause"],"exampleFix":"# before\nexcept Exception:\n    raise Exception(\"Failed getting schema\")\n# after (better diagnostics)\nexcept Exception as exc:\n    logger.exception('TreasureData schema fetch failed')\n    raise Exception('Failed getting schema: {}'.format(exc))","handlingStrategy":"try-catch","validationCode":"import requests\nr = requests.get('https://api.treasuredata.com/v3/databases', headers={'Authorization': 'TD1 ' + apikey}, timeout=10)\nr.raise_for_status()","typeGuard":null,"tryCatchPattern":"try:\n    schema = ds.query_runner.get_schema()\nexcept Exception as e:\n    logger.warning('TD schema failed: %s', e)\n    schema = []","preventionTips":["Pre-validate the TD API key with a cheap API call before schema refresh","Keep last-good schema cached for graceful degradation","Patch the runner to chain the original exception for diagnosability"],"tags":["treasuredata","redash","schema","api-key"],"backgroundTag":"schema-introspection-failed","analyzedSha":"ca79fe988d81cdac9675b412f3dfcab107bc1fbc","analyzedAt":"2026-08-28T18:32:34.637Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}