Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

file.delete returns a wrong value when the files doesn't exist #2182

Closed

Description

@vicb

Environment details

  • OS: MacOs
  • Node.js version: v18.10.0
  • npm version: 8.19.2
  • @google-cloud/storage version: 6.9.5

Steps to reproduce

Try to delete a file that doesn't exists:

const response = await bucket.file('path/to/no/file').delete({ ignoreNotFound: true });

The response is:

[
  {
    error: {
      code: 404,
      message: 'No such object: airsp/tiles/10/100/601.pbf',
      errors: [Array]
    }
  },
  PassThrough {
    //...
  }
]

The first element of the array should not be here as the response is supposed to be a [r.Response]

delete(options?: DeleteOptions): Promise<[r.Response]>;

Activity

  1. added
    priority: p2
    type: bug
    on Apr 17, 2023
  2. added
    api: storage
    on Apr 17, 2023
  3. self-assigned this
    on Apr 18, 2023
  4. ddelgrosso1 commented on Apr 18, 2023

    @ddelgrosso1
    Contributor

    Hi @vicb thank you for opening this issue. Can you explain further why you think the first element should not be here? The first element is the raw response and the second element is the response body. Both of these adhere to the type of [r.Response].

  5. vicb commented on Apr 18, 2023

    @vicb
    Author

    Thanks @ddelgrosso1 for your quick attention to that bug.

    I see

    delete(options?: DeleteOptions): Promise<[r.Response]>;

    with r.Response being (node_modules/teeny-request/build/src/index.d.ts):

    export interface Response<T = any> {
        statusCode: number;
        headers: Headers;
        body: T;
        request: Request;
        statusMessage?: string;
    }

    You can see that

      {
        error: {
          code: 404,
          message: 'No such object: airsp/tiles/10/100/601.pbf',
          errors: [Array]
        }
      },

    Does not match that type, i.e. it has no statusCode.

    Also if the response is supposed to be a tuple then a [Response, Response] type would be more appropriate.

  6. ddelgrosso1 commented on Apr 18, 2023

    @ddelgrosso1
    Contributor

    @vicb thank you for clarifying (and nice catch!), I see the problem now. It looks like the first item is actually of type ResponseBody which is set to any. Let me see if there is a decent way to fix this without making signature changes or type changes as these would necessitate a major version bump of the library.

  7. added
    next major: breaking change
    priority: p3
    and removed
    priority: p2
    on Jun 1, 2023
  8. ddelgrosso1 commented on Aug 3, 2023

    @ddelgrosso1
    Contributor

    Released with 7.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: storagenext major: breaking changepriority: p3type: bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions