cathive / concourse-chartmuseum-resource

interacts with a Chart Museum instance or Harbor (Kubernetes Helm Charts storage)
Apache License 2.0
14 stars 9 forks source link

Error uploading file #13

Closed Rambatino closed 4 years ago

Rambatino commented 4 years ago

Hello, I'm getting:

An unexpected error occured.
TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be one of type string or Buffer. Received type object

I've obviously set up something wrong, but it's squashing the error.

I imagine it's because 'e' here is an object, when really we require a string (or buffer).

Is it possible to add a JSON.stringify(e) into the stderr write?

    let postResult: Response;
    try {
        let postUrl = `${request.source.server_url}`;
        if (request.params.force) {
            postUrl += "?force=true"
        }
        postResult = await fetch(postUrl, {
            method: "POST",
            headers: headers,
            body: body
        });
    } catch (e) {
        process.stderr.write(`Upload of chart file to "${request.source.server_url}" has failed.\n`);
        process.stderr.write(e);
        process.exit(124);
        throw e; // Tricking the typescript compiler.
    }
headcr4sh commented 4 years ago

You are right. I'll replace the various bogus portions of the code where objects are thrown to stderr without any further checking.

headcr4sh commented 4 years ago

Duplicat of #7