Skip to content
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

'Parse Error: Invalid header value char' when downloading a file with name containing 'ÿ' #517

Closed
4 tasks done
etiennebatise opened this issue Jun 19, 2020 · 3 comments
Closed
4 tasks done
Assignees
Labels

Comments

@etiennebatise
Copy link

Description of the Issue

I am trying to download a file with a name containing the special character ÿ and the client throws an error.

For instance:
image

Steps to Reproduce

  • Create a file with a name containing the character ÿ.
  • Get the box id of that file
  • Call the following code
client = <insert box sdk init>
id = <insert box file id>
const tmpFile = `/tmp/${id}`
const stream = await client.files.getReadStream(id)
const out = fs.createWriteStream(tmpFile)

// Wait for download to be over
await new Promise((resolve, reject) => {
  stream.on('error', err => {
    reject(err)
  })
  stream.on('end', function () {
    resolve()
  })
  stream.pipe(out)
})

console.log(tmpFile)

Expected Behavior

It should not crash.
Alternatively, it should crash with a better error. Maybe something like Filename contains unsupported characters.

Error Message, Including Stack Trace

It throws an error with the following stack trace:

Error: Parse Error: Invalid header value char
    at TLSSocket.socketOnData (_http_client.js:479:22)
    at TLSSocket.emit (events.js:316:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:273:9)
    at TLSSocket.Readable.push (_stream_readable.js:214:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:186:23)

I also have the following error code in my log:

  "code": "HPE_INVALID_HEADER_TOKEN",

I am pretty sure other weird characters would raise the same error.

Versions Used

Node SDK: 1.32.0

@sujaygarlanka
Copy link
Contributor

@etiennebatise I am not able to replicate this issue. I was able to download a file with the special character ÿ. I used the code below

client.files.getReadStream('file_id', null, function(error, stream) {

	if (error) {
		// handle error
	}

	// write the file to disk
	var output = fs.createWriteStream('/Users/sgarlanka/Desktop/ÿellow.pdf');
	stream.pipe(output);
});

@PJSimon
Copy link
Contributor

PJSimon commented Jun 27, 2020

Hi @etiennebatise ,

Are you still having this issue or was Sujay able to help you resolve it? I'll close it for now, but if you still need help, please just re-open and comment!

Thanks!

@PJSimon PJSimon closed this as completed Jun 27, 2020
@etiennebatise
Copy link
Author

etiennebatise commented Nov 24, 2020

Hello again,

I come back after a while to confirm this is still happening in 1.35. @sujaygarlanka , I can't tell if your test has the same context. In my case, the bug happens when the file on box has a ÿ in its name. The local file name is unimportant.

After a bit of digging, I found out issues with a similar stack trace mentioning the http-parser of nodejs. See:

I can't confirm this is related but that might be a good starting point. I have tried to follow the call stack of files.getReadStream but I couldn't find where the download happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants