{"record":{"id":"9e720871e3bdd590","repo":"infiniflow/ragflow","slug":"bigquery-credentials-not-loaded","errorCode":null,"errorMessage":"BigQuery credentials not loaded.","messagePattern":"BigQuery credentials not loaded\\.","errorType":"validation","errorClass":"ConnectorMissingCredentialError","httpStatus":null,"severity":"error","filePath":"common/data_source/bigquery_connector.py","lineNumber":178,"sourceCode":"        elif isinstance(raw, dict):\n            service_account_info = raw\n        else:\n            raise ConnectorMissingCredentialError(\"BigQuery: service_account_json must be a JSON string or object\")\n\n        self._credentials = {\"service_account_info\": service_account_info}\n        return None\n\n    def _get_client(self):\n        \"\"\"Create and cache a BigQuery client from the loaded service account.\"\"\"\n        if self._client is not None:\n            return self._client\n\n        if bigquery is None or service_account is None:\n            raise ConnectorValidationError(\"BigQuery client not installed. Please install google-cloud-bigquery.\")\n\n        service_account_info = self._credentials.get(\"service_account_info\")\n        if not service_account_info:\n            raise ConnectorMissingCredentialError(\"BigQuery credentials not loaded.\")\n\n        try:\n            creds = service_account.Credentials.from_service_account_info(service_account_info)\n        except Exception as exc:\n            raise ConnectorValidationError(f\"Failed to build BigQuery credentials: {exc}\")\n\n        try:\n            self._client = bigquery.Client(\n                project=self.project_id or None,\n                credentials=creds,\n                location=self.location or None,\n            )\n        except Exception as exc:\n            raise ConnectorValidationError(f\"Failed to create BigQuery client: {exc}\")\n\n        return self._client\n\n    # ------------------------------------------------------------------ #","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/common/data_source/bigquery_connector.py#L160-L196","documentation":"Internal-consistency guard in _get_client: the cached self._credentials dict has no service_account_info entry, meaning load_credentials never ran (or ran with a shape that did not populate it). Distinct from error 533: here the load step was skipped entirely rather than given a missing key.","triggerScenarios":"Calling _get_client (directly or via validate_connector_settings / query execution) on a connector instance where load_credentials was never invoked — _credentials stays empty ({}), so .get('service_account_info') returns None and this raises ConnectorMissingCredentialError.","commonSituations":"Orchestration that constructs the connector and jumps straight to validation/queries, or a partial re-initialization path that resets _credentials without re-loading them.","solutions":["Call load_credentials(credentials) before any operation that builds a client","Verify load_credentials did not raise earlier and leave the object half-initialized","In orchestration code, treat connector construction + load_credentials as one atomic setup step"],"exampleFix":"# before\nconnector = BigQueryConnector(...)\nconnector.validate_connector_settings()  # triggers _get_client\n\n# after\nconnector = BigQueryConnector(...)\nconnector.load_credentials(creds)\nconnector.validate_connector_settings()","handlingStrategy":"validation","validationCode":"def build_bigquery_connector(creds: dict):\n    connector = BigQueryConnector(project_id=..., location=...)\n    connector.load_credentials(creds)   # must precede any client use\n    return connector","typeGuard":null,"tryCatchPattern":"try:\n    connector._get_client()\nexcept ConnectorMissingCredentialError as e:\n    if \"credentials not loaded\" in str(e):\n        connector.load_credentials(creds)\n        return connector._get_client()\n    raise","preventionTips":["Enforce construction order with a factory: new connector -> load_credentials -> use","Do not reset or partially reinitialize connector state in refresh paths","Unit-test the lifecycle: constructing without load_credentials must raise, loading then using must not"],"tags":["bigquery","gcp","lifecycle","initialization","connector"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}