{"record":{"id":"a46735ee1ba0e259","repo":"bytebase/bytebase","slug":"google-cloud-translation-api-error-data-error","errorCode":null,"errorMessage":"Google Cloud Translation API Error: ${data.error?.message || \"Unknown error\"}\\nPlease create .env.i18n locally and set GOOGLE_TRANSLATE_API_KEY=xxx.","messagePattern":"Google Cloud Translation API Error: (.+?)\\\\nPlease create \\.env\\.i18n locally and set GOOGLE_TRANSLATE_API_KEY=xxx\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/i18n.ts","lineNumber":72,"sourceCode":"  }\n\n  const response = await fetch(url, {\n    method: \"POST\",\n    headers: {\n      \"Content-Type\": \"application/json\",\n    },\n    body: JSON.stringify({\n      q: sourceText,\n      target: targetLang,\n      source: SOURCE_LANG.split(\"-\")[0],\n      format: \"text\",\n    }),\n  });\n\n  const data = await response.json();\n\n  if (!response.ok) {\n    throw new Error(\n      `Google Cloud Translation API Error: ${data.error?.message || \"Unknown error\"}\\nPlease create .env.i18n locally and set GOOGLE_TRANSLATE_API_KEY=xxx.`\n    );\n  }\n\n  let translatedText = data.data.translations[0].translatedText;\n  for (const replacement of replacements) {\n    translatedText = translatedText.replace(\n      replacement.target,\n      replacement.source\n    );\n  }\n  return translatedText;\n}\n\n// Function specifically for JsonObject translation\nasync function translateJsonObject(\n  obj: JsonObject,\n  targetLang: string","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/bytebase/bytebase/blob/1870550677fe08f0d2a78c07acd27541464eb945/frontend/i18n.ts#L54-L90","documentation":"During SQL Server metadata sync, getTableColumns runs a secondary query fetching sys.extended_properties column comments into a separate rows iterator. If iterating those rows fails (rows.Err()), the sync aborts with 'failed to fetch column comments'. Although the code intends comments to be non-critical, the current implementation returns an error instead of continuing.","triggerScenarios":"The comment query's rows iterator encounters a driver/network error during Rows.Next()/Err(), e.g. connection dropped mid-iteration after the initial query succeeded, or the query text is rejected by a specific SQL Server version (e.g. missing extended_properties support or sys.columns changes).","commonSituations":"Flaky network or SQL Server connection pool timeouts during long schema syncs; querying Azure SQL or older SQL Server editions where system catalog behavior differs; TLS/proxy dropping idle connections between the multi-statement sequence.","solutions":["Check SQL Server connectivity/stability (connection lifetime, keepalives, proxy timeouts) and retry the schema sync","Downgrade this to a logged warning: replace the return with a log statement so sync continues without comments, matching the comment's stated intent","Verify the mssql driver version and the query against the target SQL Server/Azure SQL edition; adjust the extended_properties query for compatibility","Ensure each rows iterator is closed (defer rows.Close()) before running the next query on the same connection to avoid resource conflicts"],"exampleFix":"// before\nif err := commentsRows.Err(); err != nil {\n    return nil, errors.Wrap(err, \"failed to fetch column comments\")\n}\n// after\nif err := commentsRows.Err(); err != nil {\n    log.Warn(\"failed to fetch column comments, continuing\", log.BBError(err))\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check rows.Err() after every iterator loop and log non-critical metadata failures instead of failing the whole sync","Keep connections alive for multi-query syncs: set reasonable pool idle timeouts and avoid proxies that reap idle connections","Test the sync against the exact SQL Server/Azure SQL edition in use, especially around sys.extended_properties","Ensure every rows iterator is closed before issuing the next query on the same connection"],"tags":["database","mssql","schema-sync","metadata"],"backgroundTag":"database-query-failed","analyzedSha":"1870550677fe08f0d2a78c07acd27541464eb945","analyzedAt":"2026-09-06T21:16:13.665Z","contentChangedAt":"2026-09-06T21:16:13.665Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}