Skip to content

Reading a nonexisting file succeeds #772

Description

@marekbiskup

I tried to open an nonexisting file. It succeeded and gave me the following contents:

<?xml version='1.0' encoding='UTF-8'?><Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message></Error>

I'd prefer the function threw an exception of called 'error'.

My code

  var content = '';
  var readStream = bucket.file(data.name).createReadStream();
  readStream.on('data', function(buf) { content += buf.toString(); });
  readStream.on('end', function() {
    console.log("got file data: " + content);
  });
  readStream.on('error', function(err) {
    console.log("Error opening a gcs file " + data.name + ": " + err)
  });

output:
got file data: NoSuchKeyThe specified key does not exist.

EDIT: I actually also got an error message, see below.

Activity

  1. marekbiskup commented on Jul 31, 2015

    @marekbiskup
    Author

    Sorry, I must have overlooked the log message:

    Error opening a gcs file triggers/gcsfile-VjpUNk.json: Error: Error during request.
    

    So everything is fine. I'm just surprised I also got some content.
    This is probably FAD.

  2. stephenplusplus commented on Jul 31, 2015

    @stephenplusplus
    Contributor

    Update - I originally posted an issue that turned out not to relate. I removed that to avoid the noise.

    I think this is worth taking a look at. Most likely, our universal request dispatcher needs some tweaking.

    Thanks for opening the issue!

  3. added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Jul 31, 2015
  4. added a commit that references this issue on Jul 23, 2025
  5. 5 remaining items

  6. added a commit that references this issue on Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

coretype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions