loulz0r
loulz0r•10mo ago

missing input in flow

hello everyone, i searched in the doc and in github issues, and did not found an answer for my problem, i hope it has not already been asked and i am not missing an obvious setting... I am trying in my flow to get the result of a first step and use it as an input for my second step, but i do not see the plug button or something like this... When i edit the script separately i have the inputs on the UI, but nothing in the flow screen... Someone knows what i am missing ? Thanks in advance
20 Replies
Tiago Serafim
Tiago Serafim•10mo ago
Run the first step (Test up to a on the top of the page), and then on the second step on the input fields, you can click on the plug and select on the right from the Previous Result.
No description
loulz0r
loulz0r•10mo ago
thanks, i tried this option but the plug buttons do not appear
No description
rubenf
rubenf•10mo ago
@loulz0r can you share your script with us so we can investigate ?
loulz0r
loulz0r•10mo ago
yeah sure, currently the flow is just 2 steps since i can't use the results and i was trying to debug 1. fetch data from gitlab issues 2. filter the issues if they contain a certain string
package inner

import (
"encoding/json"
"io"
"log"
"net/http"

wmill "github.com/windmill-labs/windmill-go-client"
)

// Pin dependencies partially in go.mod with a comment starting with "//require":

// the main must return (interface{}, error)

func main() (interface{}, error) {

log.Println("Starting to check devops gitlab issues...")

url, _ := wmill.GetVariable("f/gitlab/welcome_issues_url")
client := &http.Client{}

gitlabToken, _ := wmill.GetVariable("f/gitlab/gitlab_token")

req, _ := http.NewRequest("GET", url, nil)
req.Header.Set("PRIVATE-TOKEN", gitlabToken)
req.Header.Set("Content-Type", "application/json")

resp, err := client.Do(req)

if err != nil {
log.Fatal(err)
}

defer resp.Body.Close()

body, _ := io.ReadAll(resp.Body)

var issues []Issue

_ = json.Unmarshal(body, &issues)

if len(issues) == 0 {
log.Println("No new issues found, stopping here. Bye !")
return false, nil
}

log.Printf("%d issue(s) found, filtering...", len(issues))

jsonBytes, err := json.Marshal(issues)
if err != nil {
log.Fatal(err)
}

jsonString := string(jsonBytes)

return jsonString, nil
}

type Issue struct {
IID int `json:"iid"`
Description string `json:"description"`
Author map[string]interface{} `json:"author"`
}
package inner

import (
"encoding/json"
"io"
"log"
"net/http"

wmill "github.com/windmill-labs/windmill-go-client"
)

// Pin dependencies partially in go.mod with a comment starting with "//require":

// the main must return (interface{}, error)

func main() (interface{}, error) {

log.Println("Starting to check devops gitlab issues...")

url, _ := wmill.GetVariable("f/gitlab/welcome_issues_url")
client := &http.Client{}

gitlabToken, _ := wmill.GetVariable("f/gitlab/gitlab_token")

req, _ := http.NewRequest("GET", url, nil)
req.Header.Set("PRIVATE-TOKEN", gitlabToken)
req.Header.Set("Content-Type", "application/json")

resp, err := client.Do(req)

if err != nil {
log.Fatal(err)
}

defer resp.Body.Close()

body, _ := io.ReadAll(resp.Body)

var issues []Issue

_ = json.Unmarshal(body, &issues)

if len(issues) == 0 {
log.Println("No new issues found, stopping here. Bye !")
return false, nil
}

log.Printf("%d issue(s) found, filtering...", len(issues))

jsonBytes, err := json.Marshal(issues)
if err != nil {
log.Fatal(err)
}

jsonString := string(jsonBytes)

return jsonString, nil
}

type Issue struct {
IID int `json:"iid"`
Description string `json:"description"`
Author map[string]interface{} `json:"author"`
}
package inner

import (
"encoding/json"
"log"
"strings"
)

// the main must return (interface{}, error)

func main(issues string, filter string) (interface{}, error) {

var issuesArray []Issue

err := json.Unmarshal([]byte(issues), &issuesArray)
if err != nil {
log.Fatal(err)
}

log.Printf("%d issue(s) found, filtering...", len(issues))

var filteredIssues []Issue

for _, issue := range issues {
if strings.Contains(issue.DescriptionArray[0], filter) {
processDescription(issue)
filteredIssues = append(filteredIssues, issue)
}
}

if len(issues) == 0 {
log.Println("No new issues after filtration, stopping here. Bye !")
return false, nil
}

return filteredIssues, nil
}
// truncated since it's some irrelevant code
package inner

import (
"encoding/json"
"log"
"strings"
)

// the main must return (interface{}, error)

func main(issues string, filter string) (interface{}, error) {

var issuesArray []Issue

err := json.Unmarshal([]byte(issues), &issuesArray)
if err != nil {
log.Fatal(err)
}

log.Printf("%d issue(s) found, filtering...", len(issues))

var filteredIssues []Issue

for _, issue := range issues {
if strings.Contains(issue.DescriptionArray[0], filter) {
processDescription(issue)
filteredIssues = append(filteredIssues, issue)
}
}

if len(issues) == 0 {
log.Println("No new issues after filtration, stopping here. Bye !")
return false, nil
}

return filteredIssues, nil
}
// truncated since it's some irrelevant code
summary: New flow
description: ''
value:
modules:
- id: b
value:
type: script
input_transforms: {}
path: f/devops/gitlab_scripts/fetch_gitlab_issues
tag_override: null
- id: a
value:
type: script
input_transforms: {}
path: f/devops/gitlab_scripts/gitlab_filter_issues
tag_override: null
same_worker: false
concurrency_time_window_s: 0
schema:
$schema: https://json-schema.org/draft/2020-12/schema
type: object
order: []
properties: {}
required: []
ws_error_handler_muted: false
summary: New flow
description: ''
value:
modules:
- id: b
value:
type: script
input_transforms: {}
path: f/devops/gitlab_scripts/fetch_gitlab_issues
tag_override: null
- id: a
value:
type: script
input_transforms: {}
path: f/devops/gitlab_scripts/gitlab_filter_issues
tag_override: null
same_worker: false
concurrency_time_window_s: 0
schema:
$schema: https://json-schema.org/draft/2020-12/schema
type: object
order: []
properties: {}
required: []
ws_error_handler_muted: false
rubenf
rubenf•10mo ago
I cannot reproduce that you can't see the step inputs can you try deleting that step and picking it again
loulz0r
loulz0r•10mo ago
still no inputs 😦 if i try with a inline script in go, i can see the plug buttons, but nothing with my scripts
rubenf
rubenf•10mo ago
Can you check what is the schema of that script ? go to the script and lookup the schema
loulz0r
loulz0r•10mo ago
the yaml ? like this : schema: $schema: 'https://json-schema.org/draft/2020-12/schema' type: object properties: {} required: [] it seems i am missing some properties like this : schema: $schema: 'https://json-schema.org/draft/2020-12/schema' type: object properties: filter: type: string description: '' default: null issues: type: array description: '' default: null items: type: object required: - issues - filter ok, when i try to edit the parameter of the main function, the script.yaml file is not updated how do i force the update of my script.yaml file ?
rubenf
rubenf•10mo ago
we have a new command in the CLI you need to be on latest wmill upgrade and then 'wmill script generate-metadata <path>'
loulz0r
loulz0r•10mo ago
it throws an error : error: Uncaught (in promise) Error: Invalid language
rubenf
rubenf•10mo ago
@guillaume ^ what is the command that you ran it with? i mean what is the full path?
loulz0r
loulz0r•10mo ago
i'm at the root of my windmill dir : $HOME/Projects/windmill and i've tried : wmill script generate-metadata f
guillaume
guillaume•10mo ago
It's wmill script generate-metadata <path> <language>. language being go in this case I believe
loulz0r
loulz0r•10mo ago
wmill script generate-metadata f/devops ah let me try
guillaume
guillaume•10mo ago
oh wait no i'm wrong sorry
rubenf
rubenf•10mo ago
@loulz0r use the full path of your script
guillaume
guillaume•10mo ago
Ruben is correct, it's wmill script generate-metadata <path_to_the_file> path should be f/folder/script.go with the extension
rubenf
rubenf•10mo ago
@guillaume nit, we need a better error 😄
guillaume
guillaume•10mo ago
Will fix
loulz0r
loulz0r•10mo ago
merci messieurs 🙂