{"record":{"id":"55250108bc47c76c","repo":"ToolJet/ToolJet","slug":"query-could-not-be-completed-552501","errorCode":null,"errorMessage":"Query could not be completed","messagePattern":"Query could not be completed","errorType":"exception","errorClass":"QueryError","httpStatus":null,"severity":"error","filePath":"plugins/packages/gcs/lib/index.ts","lineNumber":34,"sourceCode":"          break;\n        case 'list_files':\n          result = await listFiles(client, queryOptions);\n          break;\n        case 'get_file':\n          result = await getFile(client, queryOptions);\n          break;\n        case 'upload_file':\n          result = await uploadFile(client, queryOptions);\n          break;\n        case 'signed_url_for_get':\n          result = await signedUrlForGet(client, queryOptions);\n          break;\n        case 'signed_url_for_put':\n          result = await signedUrlForPut(client, queryOptions);\n          break;\n      }\n    } catch (error) {\n      throw new QueryError('Query could not be completed', error.message, {});\n    }\n\n    return {\n      status: 'ok',\n      data: result,\n    };\n  }\n\n  async testConnection(sourceOptions: SourceOptions): Promise<ConnectionTestResult> {\n    const client: Storage = await this.getConnection(sourceOptions);\n    await listBuckets(client, {});\n\n    return {\n      status: 'ok',\n    };\n  }\n\n  async getConnection(sourceOptions: SourceOptions): Promise<any> {","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/ToolJet/ToolJet/blob/20602a8e101f2e59686c9afde0d1402aac2c8871/plugins/packages/gcs/lib/index.ts#L16-L52","documentation":"The GCS plugin wraps its operation switch (list_buckets, list_files, get_file, upload_file, signed_url_for_get, signed_url_for_put) in a try/catch that re-throws any failure as QueryError 'Query could not be completed' with error.message as description. Notably there is NO default case, so an unknown operation silently returns an empty result ({}) rather than erroring — only genuine @google-cloud/storage failures are caught here.","triggerScenarios":"list_buckets fails because the service account lacks storage.buckets.list. list_files/get_file against a non-existent bucket or object. upload_file with an invalid destination path or insufficient storage.objects.create permission. signed_url_for_get/put when the private_key is malformed so signing fails. Network error reaching the GCS JSON API.","commonSituations":"Service account JSON missing or with a corrupted private_key (\\n not unescaped). Project ID mismatch between the key and where buckets live. Bucket in a different region/project not granted to the principal. HMAC or OAuth scope too narrow for signed URL generation. Large upload_file payload exceeding limits.","solutions":["Read the QueryError.description — it carries the @google-cloud/storage message (e.g. 'The specified bucket does not exist').","Confirm the private_key JSON is complete and the service account has the required Storage IAM role (roles/storage.objectViewer / objectAdmin / admin as needed).","Verify the bucket name and that it belongs to the key's project (or is shared with the principal).","For signed URLs, ensure the private_key has correct newline escaping."],"exampleFix":"// before — bucket name typo\nqueryOptions = { operation: 'list_files', bucket: 'mybucket' };\n// after\nqueryOptions = { operation: 'list_files', bucket: 'my-bucket' };","handlingStrategy":"validation","validationCode":"function validateGcsQuery(qo) {\n  const OPS = ['list_buckets','list_files','get_file','upload_file','signed_url_for_get','signed_url_for_put'];\n  if (!OPS.includes(qo.operation)) { /* note: unknown op returns empty {}, not an error */ return; }\n  if (['list_files','get_file','upload_file'].includes(qo.operation) && !qo.bucket) throw new Error('bucket required');\n}","typeGuard":"function isGcsOperation(op: unknown): op is 'list_buckets'|'list_files'|'get_file'|'upload_file'|'signed_url_for_get'|'signed_url_for_put' {\n  return typeof op === 'string' && ['list_buckets','list_files','get_file','upload_file','signed_url_for_get','signed_url_for_put'].includes(op);\n}","tryCatchPattern":"try { await plugin.run(sourceOptions, queryOptions); }\ncatch (e) { if (e instanceof QueryError && e.message === 'Query could not be completed') { console.error('GCS detail:', e.description); } else throw e; }","preventionTips":["Paste the full, unmodified service account JSON; ensure private_key newlines are intact.","Grant the principal the right Storage IAM role for the operation.","Confirm bucket names and that they belong to the key's project."],"tags":["gcs","google-cloud-storage","query-error","iam","tooljet"],"backgroundTag":null,"analyzedSha":"20602a8e101f2e59686c9afde0d1402aac2c8871","analyzedAt":"2026-08-13T05:58:54.221Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}