Skip to content

fix(storage): stop leaking transport options in File.delete() URL - #9977

Open
thiyaguk09 wants to merge 2 commits into
googleapis:mainfrom
thiyaguk09:fix/file-delete-query-params
Open

thiyaguk09 wants to merge 2 commits into
googleapis:mainfrom
thiyaguk09:fix/file-delete-query-params

Conversation

@thiyaguk09

Copy link
Copy Markdown
Contributor

Description

Remove leaked gaxios transport options from File.delete() query parameters.

Impact

Prevents DELETE requests from sending invalid responseType and validateStatus parameters.

Changes

  • Remove unused responseType: 'text', validateStatus, and unreachable 404/403 response checks from File.delete(), forwarding options directly to super.delete(options).
  • Remove unused GaxiosOptions import from handwritten/storage/src/file.ts.

Testing

  • Updated File delete unit tests in handwritten/storage/test/file.ts to use sandbox.stub(...) on fresh instances.
  • Verified queryParameters and the serialized outgoing DELETE URL omit responseType, validateStatus, and ignoreNotFound, do not mutate caller options, and forward ifGenerationMatch, userProject, generation, and precondition query params.
  • Added File.delete() tests for ignoreNotFound: true (Promise with and without err.response, plus callback), non-ignored 404 rejections, and retryOptions.autoRetry restoration.
  • Ran pnpm run lint and pnpm test in handwritten/storage.

Fixes #9874

Remove unused responseType and validateStatus transport options (and unreachable 404/403 response checks) from File.delete() so they are not spread into ServiceObject.delete() queryParameters, and add unit test coverage.

Fixes googleapis#9874
@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label Nov 25, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request simplifies the delete method in the File class by delegating directly to the superclass's delete method, removing custom error handling and request option overrides. The corresponding unit tests have been refactored and expanded to cover various scenarios, including verifying that transport options are omitted and testing the behavior of the ignoreNotFound option. Feedback suggests asserting directly on gaxiosOpts.params in the tests to avoid unnecessary URL serialization and parsing, and typing the caught error in assert.rejects as Error & {code?: number} instead of GaxiosError to prevent potential TypeScript compilation or linting errors.

Comment thread handwritten/storage/test/file.ts Resolved
Comment thread handwritten/storage/test/file.ts Resolved
@thiyaguk09
thiyaguk09 marked this pull request as ready for review November 25, 2026 10:23
@thiyaguk09
thiyaguk09 requested review from a team as code owners November 25, 2026 10:23

This branch has not been deployed

No deployments
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 Cloud Storage API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

storage 9.0.0: File.delete() sends its own request options (responseType, validateStatus) as query parameters

1 participant