Skip to content

fix(storage): stop File.delete sending transport options as query params - #9952

Open
yeegz wants to merge 1 commit into
googleapis:mainfrom
yeegz:fix/9874-storage-delete-query-params
Open

yeegz wants to merge 1 commit into
googleapis:mainfrom
yeegz:fix/9874-storage-delete-query-params

Conversation

@yeegz

@yeegz yeegz commented Nov 23, 2026

Copy link
Copy Markdown

Fixes #9874.

File.delete added responseType and validateStatus to the options it passed to ServiceObject.delete, which spreads all options into queryParameters. So every delete URL carried ?responseType=text&validateStatus=<function source>.

Neither option did anything as a transport option either: StorageTransport.makeRequest sets its own validateStatus, and a 404 still reaches File.delete through the ignoreNotFound path in ServiceObject.delete. So this just passes the caller's options through.

Added a test in test/file.ts that checks the query parameters; it fails before the change. The storage unit tests pass (1105).

File.delete put responseType and validateStatus into the options it
passed to ServiceObject.delete, which spreads every option into
queryParameters. Both ended up in the DELETE URL, including the source
of the validateStatus function. The transport sets its own
validateStatus, so neither option had any effect; pass the caller's
options through instead.

Fixes googleapis#9874
@yeegz
yeegz requested review from a team as code owners November 23, 2026 01:53
@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label Nov 23, 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 File by directly passing the spread options to super.delete and removing local request options, and adds a unit test to verify transport options are not sent as query parameters. The review feedback points out that directly overwriting STORAGE.storageTransport.makeRequest in the test can cause test pollution, and suggests using sandbox.stub(object, 'method') instead for proper cleanup.

Comment on lines +236 to +238
STORAGE.storageTransport.makeRequest = sandbox
.stub()
.callsFake((reqOpts, callback) => {

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.

medium

Directly overwriting STORAGE.storageTransport.makeRequest with a stub can lead to test pollution because sandbox.restore() will not automatically restore the original method. Instead, use sandbox.stub(object, 'method') to ensure proper cleanup after the test runs.

Suggested change
STORAGE.storageTransport.makeRequest = sandbox
.stub()
.callsFake((reqOpts, callback) => {
sandbox
.stub(STORAGE.storageTransport, 'makeRequest')
.callsFake((reqOpts, callback) => {
References
  1. Use makeRequest rather than request when invoking HTTP requests on StorageTransport instances.

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