feat: add storage batch operations samples#2
Open
thiyaguk09 wants to merge 40 commits into
Open
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a set of new Node.js samples for Google Cloud Storage Batch Operations, covering essential functionalities like creating, retrieving, listing, canceling, and deleting jobs. My review highlights a recurring critical issue across all the new JavaScript files: asynchronous operations are not being properly awaited. This could cause the scripts to terminate prematurely before the operations complete. I have provided suggestions to refactor the code to use async/await correctly and implement a more robust error handling pattern. Additionally, I've noted a minor naming inconsistency in one file and a formatting issue in the package.json file.
mahendra-google
approved these changes
Sep 12, 2025
e7476df to
c1d08bd
Compare
c1d08bd to
b424e2c
Compare
fb51efe to
6f5d870
Compare
…on & Error Handling) Improve the robustness and clarity of the Storage Batch Operations API samples: * **Error Handling:** Wraps all asynchronous Batch Operations API samples (Create, Get, List, Cancel) in `try...catch` blocks for production readiness. * **Specific Diagnostics:** Adds specific gRPC error code checks (`NOT_FOUND`, `FAILED_PRECONDITION`) within the `catch` blocks to provide detailed diagnostic feedback to users regarding job state or non-existence. * **Documentation:** Clarifies JSDoc for all function parameters (e.g., `projectId`, `jobId`, `objectPrefix`), ensuring examples and types are clear for developers.
6f5d870 to
7dceecc
Compare
…orcement (GoogleCloudPlatform#4272) * feat(storage): add samples and system tests for bucket encryption enforcement Adds comprehensive code samples and system tests to verify Google-managed, Customer-managed, and Customer-supplied encryption enforcement logic. - Add setBucketEncryptionEnforcementConfig.js sample - Add getBucketEncryptionEnforcementConfig.js sample - Add updateBucketEncryptionEnforcementConfig.js sample - Add system tests to verify CLI output and backend metadata state - Ensure server-side effectiveTime is correctly captured and displayed * code refactor * test(storage): refactor encryption tests to assert state over strings * test: skip bucket encryption enforcement tests if defaultKmsKeyName is missing --------- Co-authored-by: Jennifer Davis <sigje@google.com>
…oudPlatform#4276) * Feat(storage): add Object Contexts samples and system tests - Add `setObjectContexts.js` to demonstrate CRUD and deletion of contexts. - Add `getObjectContexts.js` to show retrieval of structured metadata. - Add `listObjectsWithContextFilter.js` to demonstrate server-side filtering. - Implement comprehensive system tests in `files.test.js` covering presence, absence (-), and existence (:) filter operators. - Ensure samples use correct 'contexts' field with 'custom' map structure. * code refactor * fix: typo corrections * test(storage): refactor to state-based assertions --------- Co-authored-by: Jennifer Davis <sigje@google.com>
…using unique UUIDs (GoogleCloudPlatform#4320) * test(secret-manager): fix ALREADY_EXISTS in delayed destroy tests by using unique UUIDs * test(secret-manager): ensure resource cleanup on assertion failure using try-finally
…dPlatform#4317) * test(talent): add explicit delay to wait for job indexing * test(talent): move indexing delay to before hook to avoid waiting on every retry --------- Co-authored-by: Jennifer Davis <sigje@google.com>
…t api tests (GoogleCloudPlatform#4318) * test(scc): fix concurrent modification error in custom module tests * test(security-center): fix ALREADY_EXISTS resource leaks and unhandled API rejections * chore(security-center): disable parallel test execution to prevent API concurrency collisions --------- Co-authored-by: Jennifer Davis <sigje@google.com>
…ples (GoogleCloudPlatform#4321) * fix(genai): resolve module path and naming issues in count-tokens samples * style: ensure consistent .js extension in require statements
…public access prevention (GoogleCloudPlatform#4327) Co-authored-by: Jennifer Davis <sigje@google.com>
…sure conversation readiness (GoogleCloudPlatform#4322) * fix: add delay to createAnalysis test to ensure conversation readiness * fix: use delay helper for consistent analysis test stability * test: increase delay in createAnalysis to improve CI stability * test: refactor CreateAnalysis test to separate conversation creation into before hook * fix: correct exponential backoff delay in tests to prevent RESOURCE_EXHAUSTED errors * fix: resolve RESOURCE_EXHAUSTED quota errors in CI pipeline * test: increase delays and backoff to fix flaky GCP quota errors * test: add try-catch block to createAnalysis to expose hidden errors in CI * test: skip on gRPC error 13 and reduce wait time in CI - Intercept gRPC error 13 (INTERNAL) in createAnalysis test to skip execution and avoid false red pipelines. - Keep default retry behavior for quota or other transient errors. - Reduce initial setTimeout delay from 65s to 5s to optimize CI speed. --------- Co-authored-by: Jennifer Davis <sigje@google.com>
…vent 401 errors in CI pipeline (GoogleCloudPlatform#4325) * fix: mock sendgrid SDK to prevent 401 errors in CI pipeline * fix: mock sendgrid package and add payload assertions to function tests
…alidation (GoogleCloudPlatform#4313) * fix(slack): replace deprecated @slack/events-api with native crypto validation * fix(slack): inject fallback environment variables for unit test CI compatibility * test(slack): apply code review feedback and add mock data for CI * chore(slack): downgrade nock to v13 to support legacy Node.js versions in CI matrix * refactor(slack): replace kgsearch callbacks with native async/await
…rors (GoogleCloudPlatform#4315) * test(asset): add sleep retries to prevent RESOURCE_EXHAUSTED quota errors * test(asset): removed unused Storage and BigQuery setup/teardown in org policy tests to reduce API quota consumption and execution time. * test(asset): increase initial sleep timeout to 1 minute to mitigate ListAssets quota exhaustion * test: add retry logic and skip fallback for ListAssets quota errors
…nai (GoogleCloudPlatform#4330) * refactor: migrate countTokens samples to @google/genai, update config, and remove deprecated totalBillableCharacters * refactor(samples): migrate function-calling samples to @google/genai using message structure for tool responses * feat(generative-ai): migrate grounding samples to new GenAI SDK * feat(generative-ai): migrate text and multimodal inference samples to @google/genai * refactor(generative-ai): migrate first batch of inference samples to @google/genai and skip remaining tests * refactor(generative-ai): update model to gemini-2.5-flash and fix streaming text accumulation
…#4177) * feat(storagecontrol): Add samples for Storage Anywhere Cache * add testcase * lint fix * fix: test case * fix: remove cacheName * skip test case * test case remove projectId * addressing review comments * index on anywhere-cache-samples: e83ba77 addressing review comments * feat(storage-control): Improve Anywhere Cache API samples Improve Anywhere Cache API samples (Documentation & Error Handling) * Wraps all asynchronous Anywhere Cache API samples (Create, Get, List, Disable, Pause, Resume) in `try...catch` blocks for production readiness. * Adds specific gRPC error code checks (NOT_FOUND, FAILED_PRECONDITION) to provide better diagnostic feedback to users. * Clarifies documentation regarding the optional nature and default values of `ttl` and `admissionPolicy` for cache creation. * test(storagecontrol): Enhance Anywhere Cache test assertions and coverage Updates tests for all Anywhere Cache management methods (Create, Get, List, Resume, Disable, Pause) to align with enhanced sample script output. **(Tests were skipped due to reliance on Long-Running Operations (LROs) in the sample code.)** This includes: * **Enhanced Assertions:** Asserting against all newly added detail fields (e.g., Name, State, TTL) to verify full API response parsing in Get and List samples. * **Negative Scenario Coverage:** Adding explicit **negative scenario tests** for state-dependent operations (Disable, Pause, Resume) to assert graceful failure on expected errors like `FAILED_PRECONDITION`. * Fix: Remove duplicate call to disableAnywhereCache The function was being called twice due to an oversight during a recent try/catch restructure. --------- Co-authored-by: Katie McLaughlin <katie@glasnt.com> Co-authored-by: Jennifer Davis <sigje@google.com> Co-authored-by: Chandra Shekhar Sirimala <chandrashekhar.siri@gmail.com>
…mentation (GoogleCloudPlatform#4332) Co-authored-by: Angel Caamal <acaamalcanul@google.com> Co-authored-by: Jennifer Davis <sigje@google.com>
…oudPlatform#4314) Co-authored-by: Jennifer Davis <sigje@google.com>
…gle/genai (GoogleCloudPlatform#4331) * refactor: migrate batch 2 generative-ai samples to @google/genai * test: add LOCATION fallback and update model to gemini-2.5-flash in translate test --------- Co-authored-by: Jennifer Davis <sigje@google.com>
…udPlatform#4316) * chore: remove unused datastore folder without region tags * build: clean up dangling CI references to deleted datastore samples * ci: temporarily restore datastore-functions.yaml to bypass zizmor The datastore-functions samples and workflow were deleted in a previous commit. However, the Zizmor scanner fails with an 'invalid input' error when attempting to audit the deleted file from the PR diff. This commit restores a dummy workflow to unblock the CI pipeline until the scanning infrastructure is updated to ignore deleted files. * chore: add missing Apache 2.0 copyright header to dummy workflow * ci: add explicit permissions and trailing newline to satisfy CodeQL --------- Co-authored-by: Jennifer Davis <sigje@google.com>
…nai fold…" (GoogleCloudPlatform#4337) This reverts commit 7517761.
…nai folder (Batch 1)" (GoogleCloudPlatform#4339) * Revert "refactor(genai): migrate region tags from generative-ai to genai folder (Batch 2) (GoogleCloudPlatform#4336)" This reverts commit 7517761. * Revert "refactor(genai): migrate region tags from generative-ai to genai folder (Batch 1) (GoogleCloudPlatform#4335)" This reverts commit f2465a6.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #
Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.
Checklist
npm test(see Testing)npm run lint(see Style)GoogleCloudPlatform/nodejs-docs-samples. Not a fork.