[GH-ISSUE #1187] Both no bucket and no file are return 404 and NotFound. So I can't handle these. #175

Open
opened 2026-03-03 12:08:55 +03:00 by kerem · 1 comment
Owner

Originally created by @username1103 on GitHub (May 29, 2023).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/1187

Hi, I'm use this library with nodejs.

  const [result] = await this.client
    .bucket(this.config.options.bucket)
    .file(key)
    .download();

  return new File(key, result);

I want to handle no bucket error and no such key error.
When connected to actual cloud storage, I was able to distinguish it through messages. "The specified bucket does not exist", "No such object".

However, when using fake-gcs-server, even if there is no bucket or no object, the same error 404 ApiError: NotFound is provided, so it cannot be distinguished.

I received message "No such object" if object does not exist and bucket exists in actual cloud storage.
And received message "The specified bucket does not exist" if bucket does not exists in acual cloud storage.

Is there a way to handle both errors?

Originally created by @username1103 on GitHub (May 29, 2023). Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/1187 Hi, I'm use this library with nodejs. ```typescript const [result] = await this.client .bucket(this.config.options.bucket) .file(key) .download(); return new File(key, result); ``` I want to handle no bucket error and no such key error. When connected to actual cloud storage, I was able to distinguish it through messages. "The specified bucket does not exist", "No such object". However, when using fake-gcs-server, even if there is no bucket or no object, the same error 404 ApiError: NotFound is provided, so it cannot be distinguished. I received message "No such object" if object does not exist and bucket exists in actual cloud storage. And received message "The specified bucket does not exist" if bucket does not exists in acual cloud storage. Is there a way to handle both errors?
Author
Owner

@fsouza commented on GitHub (May 29, 2023):

We should try to make the messages the same (though that's very tricky as the actual error messages are not part of the API, so they could change at anytime).

<!-- gh-comment-id:1566531844 --> @fsouza commented on GitHub (May 29, 2023): We should try to make the messages the same (though that's very tricky as the actual error messages are not part of the API, so they could change at anytime).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/fake-gcs-server#175
No description provided.