Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Unsupported protocol scheme #46

Closed
bookmoons opened this issue Nov 3, 2019 · 6 comments · Fixed by #47
Closed

Unsupported protocol scheme #46

bookmoons opened this issue Nov 3, 2019 · 6 comments · Fixed by #47

Comments

@bookmoons
Copy link
Contributor

A runtime error is observed with a certain collection:

Get : unsupported protocol scheme ""

Reported by @danni-popova in #43.

@bookmoons
Copy link
Contributor Author

Example conversion result that hits the error.

// Auto-generated by the Load Impact converter

import "./libs/spo-gpo.js";
import "./libs/shim/core.js";
import URI from "./libs/urijs.js";
import aws4 from "./libs/aws4.js";

export let options = { maxRedirects: 4 };

const Request = Symbol.for("request");
postman[Symbol.for("initial")]({
  options
});

export default function() {
  postman[Request]({
    name: "discovery",
    id: "aa538977-373a-463b-937a-f371ddd71968",
    method: "GET",
    address:
      "https://{replaced_url}",
    auth(config, Var) {
      const address = new URI(config.address);
      const options = {
        method: "GET",
        protocol: address.protocol(),
        hostname: address.hostname(),
        port: address.port(),
        path: address.path() + address.search(),
        region: "eu-west-1",
        service: "cf"
      };
      const credential = {
        accessKeyId: "{replaced_access_key}",
        secretAccessKey: "{replaced_secret_key}"
      };
      const signed = aws4.sign(options, credential);
      const [path, query] = signed.path.split("?");
      config.address = new URI()
        .protocol(address.protocol())
        .hostname(signed.hostname)
        .path(path)
        .query(query)
        .toString();
      Object.assign(config.headers, signed.headers);
    }
  });
}

@bookmoons
Copy link
Contributor Author

This might be something to do with the AWS auth logic.

@bookmoons
Copy link
Contributor Author

I remember now I saw this and thought AWS requests require a query, so it wouldn't come up. It happens when the URL has no query string. You end up with undefined and it nulls out some later values.

I'll get a patch underway, but you can work around it by changing this line:

      const [path, query] = signed.path.split("?");

To this, to default query to the right type even when it's empty:

      const [path, query = ""] = signed.path.split("?");

@danni-popova

@danni-popova
Copy link

That worked! Thank you ever so much for looking into this!

@bookmoons
Copy link
Contributor Author

Quite welcome!

@bookmoons
Copy link
Contributor Author

Opened #47 to patch this.

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

Successfully merging a pull request may close this issue.

2 participants