{"record":{"id":"0625a76d75c21d41","repo":"infiniflow/ragflow","slug":"bigquery-missing-service-account-json","errorCode":null,"errorMessage":"BigQuery: missing service_account_json","messagePattern":"BigQuery: missing service_account_json","errorType":"validation","errorClass":"ConnectorMissingCredentialError","httpStatus":null,"severity":"error","filePath":"common/data_source/bigquery_connector.py","lineNumber":153,"sourceCode":"        self._cursor_param_type: Optional[str] = None\n        self._sync_connector_id: str | None = None\n        self._sync_config: Dict[str, Any] | None = None\n        self._pending_sync_cursor_value: Any = None\n        self._pending_sync_cursor_id: Any = None\n\n    # ------------------------------------------------------------------ #\n    # Credentials & client\n    # ------------------------------------------------------------------ #\n    def load_credentials(self, credentials: Dict[str, Any]) -> Dict[str, Any] | None:\n        \"\"\"Load BigQuery service-account credentials.\n\n        Accepts ``service_account_json`` as either a dict or a JSON string.\n        \"\"\"\n        logging.debug(\"Loading credentials for BigQuery project: %s\", self.project_id)\n\n        raw = (credentials or {}).get(\"service_account_json\")\n        if not raw:\n            raise ConnectorMissingCredentialError(\"BigQuery: missing service_account_json\")\n\n        if isinstance(raw, str):\n            try:\n                service_account_info = json.loads(raw)\n            except json.JSONDecodeError as exc:\n                raise ConnectorMissingCredentialError(f\"BigQuery: service_account_json is not valid JSON: {exc}\")\n        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","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/common/data_source/bigquery_connector.py#L135-L171","documentation":"BigQuery connector's load_credentials raises ConnectorMissingCredentialError when the credentials dict has no truthy 'service_account_json' entry. The value may be a dict or a JSON string; absent, empty string, or None all trigger this. No Google API call is made — it fails fast locally.","triggerScenarios":"Calling load_credentials with a dict lacking the service_account_json key, with an empty string, or with None — commonly when the credential is stored under a different key name or the secrets integration returned nothing.","commonSituations":"Secrets manager path misconfigured so the fetched secret never lands in service_account_json, key named 'service_account' or 'credentials_json' by mistake, or an empty value written during initial setup that was never filled in.","solutions":["Add 'service_account_json' to the credentials dict, either as the parsed JSON object or the raw JSON string from the GCP console","Fix the secrets-manager key mapping so the value lands under service_account_json","Sanity-check the value is non-empty before calling load_credentials"],"exampleFix":"# before\ncreds = {\"service_account\": sa_json}  # wrong key\nconnector.load_credentials(creds)\n\n# after\ncreds = {\"service_account_json\": sa_json}\nconnector.load_credentials(creds)","handlingStrategy":"validation","validationCode":"def validate_bigquery_creds(creds: dict) -> None:\n    raw = creds.get(\"service_account_json\")\n    if not raw:\n        raise ValueError(\"credentials must include a non-empty 'service_account_json'\")\n    if not isinstance(raw, (str, dict)):\n        raise TypeError(\"service_account_json must be a str or dict\")","typeGuard":"def has_service_account_json(c: dict) -> bool:\n    raw = c.get(\"service_account_json\")\n    return isinstance(raw, (str, dict)) and bool(raw)","tryCatchPattern":"try:\n    connector.load_credentials(creds)\nexcept ConnectorMissingCredentialError as e:\n    raise ConfigError(str(e)) from e  # show as form/config error","preventionTips":["Use one typed config schema (pydantic) for connector credentials validated at load time","Wire secrets-manager lookups through a single function with the exact key name 'service_account_json'","Add a config smoke test that fails CI when required credential keys go missing"],"tags":["bigquery","gcp","credentials","configuration","connector"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}