Yaak Logo
Yaak
Feedback/[Plugin] Cannot get inhereted parameters when rendering a request

[Plugin] Cannot get inhereted parameters when rendering a request

Lucas Dell'Isola·10 months ago
ReleasedBug

I am building a plugin to copy the request as a nushell http command instead of curl.

I have the following request:

The header X-API-KEY is configured for the whole workspace.

But the plugin cannot access the inherited header: X-API-KEY.
Here is a code sample:

export const plugin: PluginDefinition = {
  httpRequestActions: [
    {
      label: "Copy as Nushell http",
      icon: "copy",
      async onSelect(ctx, args) {
        const rendered_request = await ctx.httpRequest.render({
          httpRequest: args.httpRequest,
          purpose: "preview",
        });
        const xs = [""];
        addHeaders(xs, (rendered_request.headers ?? []).filter(onlyEnabled));
        await ctx.clipboard.copyText(xs.join(" "));
      },
    },
  ],
};

function addHeaders(xs: string[], headers: HttpRequestHeader[]) {
  if (headers.length == 0)
    return;
  xs.push("--headers");
  xs.push("{");
  for (const h of headers) {
    xs.push(`${h.name}: "${h.value}"`);
  }
}

This would copy on the clipboard:

--headers { Content-Type: "application/json" Accept: "application/stacked" }

instead of:

--headers { Content-Type: "application/json" Accept: "application/stacked" X-API-KEY: "SECRET" }

As far as I can tell, the export as curl plugin has the same problem

Windows2025.5.0-beta.5

Comments (5)

Sign in to leave a comment.

Gregory Schier

Ah yes, good catch. Inherited auth and headers both don’t work. I will update the code to pass the fully-resolved HttpRequest to the action 👍🏼

Gregory Schier

This is fixed in dev, so it’ll be available in the next release

Gregory Schier
Lucas Dell'IsolaOP

Thanks for the fast response!

Gregory Schier
Type to search feedback...