Skip to content

Reading a nonexisting file succeeds #772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
marekbiskup opened this issue Jul 31, 2015 · 2 comments
Closed

Reading a nonexisting file succeeds #772

marekbiskup opened this issue Jul 31, 2015 · 2 comments
Assignees
Labels
core type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@marekbiskup
Copy link

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.

@marekbiskup
Copy link
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.

@stephenplusplus
Copy link
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!

@stephenplusplus stephenplusplus added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. core labels Jul 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants