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

Allow for pipeline step parameters to be fully JSON #161

Merged
merged 4 commits into from
May 27, 2024

Conversation

joshtyf
Copy link
Owner

@joshtyf joshtyf commented May 26, 2024

Description

Previously, parameters was of type map[string]string. This meant that the user had to define all parameter values as strings. If they needed maps/lists, they would have to write as json encoded strings and our backend had to further decode these strings into a proper map/list.

I've updated the type to now be of type map[string]any. This allows the user to write the parameters normally using JSON syntax. However, this requires each step to properly type assert their parameters. I'm thinking we can further improve this and refactor in another PR to add more safety.

With this change, I can add in the request headers in a proper JSON object. Same for request data.

Others

Currently, our executor isn't handling panics well. If there is a panic, there won't be any errors shown. I believe this is because the execution is run in a separate goroutine and the panic isn't shown in the main program process.

@joshtyf joshtyf added backend Backend related refactor Code refactor or updates labels May 26, 2024
@joshtyf joshtyf self-assigned this May 26, 2024
Parameters: map[string]any{
"method": "${method}",
"url": "https://httpbin.org/${method}?param=${param}",
"data": "{\"key\": \"${value}\", \"${key}\": \"hardcoded_value\"}",
Copy link
Owner Author

@joshtyf joshtyf May 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data is currently a json encoded string. this will eventually be changed to be a proper JSON object like headers

requestMethod := step.Parameters["method"]
url := step.Parameters["url"]
requestBody := step.Parameters["data"]
requestMethod := step.Parameters["method"].(string) // TODO: add documentation for parameters, specifically the type for safe type assertion
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when creating the pipeline in the frontend, the user doesn't know what parameters are required for the API step type. he also doesn't know if the parameter value should be of what type. we can add both documentation and validation for this

Copy link
Collaborator

@Zheng-Zhi-Qiang Zheng-Zhi-Qiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@joshtyf joshtyf merged commit f2d9fa0 into main May 27, 2024
2 checks passed
@joshtyf joshtyf deleted the refactor/string-params-to-generic-interface branch May 27, 2024 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Backend related refactor Code refactor or updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants