Skip to content

Conversation

@thiyaguk09
Copy link
Contributor

Description

This PR refactors the GCS conformance test suite to use the low-level StorageTransport.makeRequest architecture instead of high-level SDK abstractions. This change is necessary to ensure that the x-retry-test-id headers are correctly propagated through the transport layer for fault-injection testing.

Key Changes:

  • Transport Refactor: Updated conformance-test/libraryMethods.ts (specifically saveResumable, lock, and createBucket) to use the low-level transport.
  • Robust Bucket Creation: Implemented "Create-or-Get" logic in createBucket to handle HTTP 409 (Conflict) errors, ensuring tests are resilient to non-empty bucket cleanup failures.
  • Dynamic Metageneration: Updated the lock function to dynamically fetch current bucket metadata before applying retention locks, resolving metageneration mismatch errors.
  • Header Normalization: Enhanced StorageTransport to consistently lowercase all response header keys, ensuring case-insensitive lookups regardless of the underlying header object type.
  • Retry Logic Improvements: Refined the shouldRetry logic to better handle malformed JSON responses and specific GCS error reasons like rateLimitExceeded.

Impact

  • Reliability: Fixes several "Scenario 1" and "Scenario 7" failures in the conformance test suite caused by high-level abstraction interference.
  • Consistency: Aligns the Node.js library with the expected GCS Resumable Upload protocol and error-handling standards.
  • Maintainability: Provides a more predictable path for injecting test-specific headers without modifying the core public API.

Testing

  • Unit Tests: Added comprehensive test cases in test/storage-transport.ts to cover shouldRetry branches, including network-level transients (ECONNRESET), malformed JSON strings, and idempotent method logic.
  • Coverage: Increased line coverage for storage-transport.ts from ~73% to over 90% by targeting previously uncovered error-handling blocks.
  • Integration Tests: Verified against the local conformance test-bench.
  • Breaking Changes: None. This refactor only affects internal test utility execution and private transport processing.

Additional Information

The refactor addresses specific issues encountered when running the suite in Node 18+ environments where gaxios and google-auth-library response structures (specifically Headers) behaved differently than in Node 14.

Checklist

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease
  • Appropriate docs were updated
  • Appropriate comments were added, particularly in complex areas or places that require background
  • No new warnings or issues will be generated from this change

Fixes #issue_number_goes_here 🦕

All 720 test cases have been fixed, and the code has been refactored.
- Replace high-level bucket and file calls with
storageTransport.makeRequest.
- Fix Scenario 1 failures by implementing "create-or-get" logic for
buckets.
- Resolve metageneration mismatch in lock() by dynamically fetching
metadata.
- Normalize header keys to lowercase in transport response processing.
- Increase unit test coverage for shouldRetry logic and error handling.
@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. api: storage Issues related to the googleapis/nodejs-storage API. labels Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the googleapis/nodejs-storage API. size: xl Pull request size is extra large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant