Kreya icon indicating copy to clipboard operation
Kreya copied to clipboard

Using variables in a REST slug has incorrect values or fails

Open iancullinane opened this issue 1 year ago • 1 comments

Describe the bug When trying to use a REST slug with a variable, there seems to be some unexpected behavior. I have a slug that takes a uuid, not a query param. I assumed I could use a variable for this but it appears to be failing, those failures also appear to inject strings that no longer exist.

To Reproduce Steps to reproduce the behavior:

  1. Params on a REST endpoint.
  2. Use a variable in the path (eg /v1/endpoint/{{ vars.uuid }}.
  3. Notice "Path Params" appears with { vars.uuid as the "Key" and nothing for the value.
  4. Call does not have the uuid in the expected position.

Addtionally, and I can't get the kreya environment to stop this behavior now that it has happened.

  1. In "Query Parameters" add a a value (eg "UserId":{{ vars.uuid }}"
  2. Remove that key
  3. Subsequent calls with {{ vars.uuid }} still have the query param (eg v1/user/%7D?%3AownerID=%7D

Expected behavior Using a variable in the slug injects it appropriately.

Screenshots If applicable, add screenshots to help explain your problem.

Environment (if possible, copy the information from the error dialog or the About menu):

  "kreyaVersion": "1.13.1",
  "releaseChannel": "stable",
  "osDescription": "Darwin 21.6.0 Darwin Kernel Version 21.6.0: Thu Jun  8 23:57:12 PDT 2023; root:xnu-8020.240.18.701.6~1/RELEASE_X86_64",
  "osVersion": "Unix 12.6.7",
  "osArch": "X64",
  "processArch": "X64",
  "runtimeIdentifier": "osx-x64",
  "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko)"

Context

When adding a variable at the end of the slug the following appears in Path Params, not sure if this is expected:

image

iancullinane avatar Feb 13 '24 16:02 iancullinane

The way this is expected to work is to configure the path as /v1/endpoint/{UserId}. This should make a "UserId" entry appear in the "Path params", whose value you can set to {{ vars.uuid }}.

A similar configuration from the example project:

grafik

I understand that this behaviour is confusing and we'll discuss if we can do anything to improve this.

CommonGuy avatar Feb 14 '24 06:02 CommonGuy

A fix for this has been implemented and was released with the newest beta release. It will be included in the next stable version.

CommonGuy avatar Mar 13 '24 14:03 CommonGuy

Kreya 1.14 has been released

CommonGuy avatar Apr 18 '24 07:04 CommonGuy