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

Code block in "trigger flow" sends variable with quotes #21263

Closed
VincentKempers opened this issue Jan 31, 2024 · 3 comments · Fixed by #22318
Closed

Code block in "trigger flow" sends variable with quotes #21263

VincentKempers opened this issue Jan 31, 2024 · 3 comments · Fixed by #22318

Comments

@VincentKempers
Copy link
Contributor

Describe the Bug

When creating a flow with a "trigger flow" you can't send {{$last}} in the payload. The linter wants you to add "". When doing so the flow return an invalid JSON error. When you go back and check the raw editor it actually sends {{$last}} with quotes.

To Reproduce

You need to create a flow with a "trigger flow" and make a simple flow that sends data through.
You need to add the {{$last}} to the code payload (you will have to do quotes here because of the linting).
Then run it and you will get this error.

{
  "name": "SyntaxError",
  "message": "Unexpected token i in JSON at position 4"
}

When you go to the raw editor you will see the quotes there and when you see it in your network tab it will show that the escaped quotes are there as well.
image

video

interface-not-handeling-value-correctly.mov

Directus Version

v10.8.3

Hosting Strategy

Self-Hosted (Docker Image)

@joselcvarela
Copy link
Member

I can confirm this issue.
The workaround is to edit Raw Value and save without double quotes ".
Although, when opening the Trigger Flow operation, it will contain the double quotes again (but it still does not have it on database).

This is specially annoying when we want to pass an array where we want to execute the other flow for each item of this list.

@joancarlesbadia
Copy link

It also happens on a "create data" step. After reading a json array from a webhook step. If the array has only one json item It returns a JSON error. If the payload json array has more than one object It works correctly.

@badrgou
Copy link

badrgou commented Mar 26, 2024

Describe the Bug

When creating a flow with a "trigger flow" you can't send {{$last}} in the payload. The linter wants you to add "". When doing so the flow return an invalid JSON error. When you go back and check the raw editor it actually sends {{$last}} with quotes.

To Reproduce

You need to create a flow with a "trigger flow" and make a simple flow that sends data through. You need to add the {{$last}} to the code payload (you will have to do quotes here because of the linting). Then run it and you will get this error.

{
  "name": "SyntaxError",
  "message": "Unexpected token i in JSON at position 4"
}

When you go to the raw editor you will see the quotes there and when you see it in your network tab it will show that the escaped quotes are there as well. image

video

interface-not-handeling-value-correctly.mov

Directus Version

v10.8.3

Hosting Strategy

Self-Hosted (Docker Image)

have u tried to trigger the other flow from API?
u you'd change the second flow to be triggered via webhook then in the first flow send a post request to that webhook
for req format see:
https://docs.directus.io/reference/system/flows.html#flow-with-post-webhook-trigger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

4 participants