windmill-labs / windmill

Open-source developer platform to power your entire infra and turn scripts into webhooks, workflows and UIs. Fastest workflow engine (13x vs Airflow). Open-source alternative to Retool and Temporal.
https://windmill.dev
Other
10.16k stars 499 forks source link

bug: When loading old flow "id is supposed to be string but got type undefined" #1364

Closed jaller94 closed 1 year ago

jaller94 commented 1 year ago

Describe the bug

I have the following flow in my workspace. Whenever I load it, I get a validation error from this file.

https://github.com/windmill-labs/windmill/blob/main/frontend/src/lib/components/FlowGraphViewer.svelte

Screenshot_2023-04-05_00-27-36

{
    "summary": "Post a list of mesh links from OpenWifiMap to a Matrix room",
    "description": "To monitor the connection quality over time this Flow fetches the mesh links from an HTTP service and posts them into a Matrix room.",
    "value": {
        "modules": [
            {
                "value": {
                    "path": "u/christian/opemwifimap_check_links",
                    "type": "script",
                    "input_transforms": {
                        "id": {
                            "type": "static"
                        }
                    }
                },
                "summary": "Fetch data from OpenWifiMap",
                "input_transforms": {
                    "id": {
                        "expr": "`${flow_input.wifi_id}`",
                        "type": "javascript"
                    }
                }
            },
            {
                "value": {
                    "path": "hub/150/matrix/post_an_unencrypted_message",
                    "type": "script",
                    "input_transforms": {
                        "body": {
                            "type": "static"
                        },
                        "room": {
                            "type": "static"
                        },
                        "matrix_res": {
                            "type": "static"
                        }
                    }
                },
                "summary": "Post to Matrix room",
                "input_transforms": {
                    "body": {
                        "expr": "`${previous_result.summary}`",
                        "type": "javascript"
                    },
                    "room": {
                        "expr": "`${flow_input.room_id}`",
                        "type": "javascript"
                    },
                    "matrix_res": {
                        "expr": "flow_input.matrix_res",
                        "type": "javascript"
                    }
                }
            }
        ]
    },
    "schema": {
        "type": "object",
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "required": [
            "room_id",
            "wifi_id",
            "matrix_res",
            "matrix_res"
        ],
        "properties": {
            "room_id": {
                "type": "string",
                "format": "",
                "description": ""
            },
            "wifi_id": {
                "type": "string",
                "format": "",
                "description": ""
            },
            "matrix_res": {
                "type": "object",
                "format": "resource-matrix",
                "description": ""
            }
        }
    }
}

To reproduce

  1. Create this flow in your workspace.
  2. Go to the flow edit page.
    1. In my case this is https://app.windmill.dev/flows/edit/u/christian/post_openwifimap_links_to_matrix

Expected behavior

Auto-fix old flows when loading them.

Screenshots

No response

Browser information

Mozilla Firefox 112.0b7

Application version

Windmill v1.85.0-16-g922682c4

Additional Context

No response

rubenfiszel commented 1 year ago

For each module, add an id of your choosing.

I fixed your flow below:

{
    "summary": "Post a list of mesh links from OpenWifiMap to a Matrix room",
    "description": "To monitor the connection quality over time this Flow fetches the mesh links from an HTTP service and posts them into a Matrix room.",
    "value": {
        "modules": [
            {
                "id": "a",
                "value": {
                    "path": "u/christian/opemwifimap_check_links",
                    "type": "script",
                    "input_transforms": {
                        "id": {
                            "type": "static"
                        }
                    }
                },
                "summary": "Fetch data from OpenWifiMap",
                "input_transforms": {
                    "id": {
                        "expr": "`${flow_input.wifi_id}`",
                        "type": "javascript"
                    }
                }
            },
            {
                "id": "b",
                "value": {
                    "path": "hub/150/matrix/post_an_unencrypted_message",
                    "type": "script",
                    "input_transforms": {
                        "body": {
                            "type": "static"
                        },
                        "room": {
                            "type": "static"
                        },
                        "matrix_res": {
                            "type": "static"
                        }
                    }
                },
                "summary": "Post to Matrix room",
                "input_transforms": {
                    "body": {
                        "expr": "`${previous_result.summary}`",
                        "type": "javascript"
                    },
                    "room": {
                        "expr": "`${flow_input.room_id}`",
                        "type": "javascript"
                    },
                    "matrix_res": {
                        "expr": "flow_input.matrix_res",
                        "type": "javascript"
                    }
                }
            }
        ]
    },
    "schema": {
        "type": "object",
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "required": [
            "room_id",
            "wifi_id",
            "matrix_res",
            "matrix_res"
        ],
        "properties": {
            "room_id": {
                "type": "string",
                "format": "",
                "description": ""
            },
            "wifi_id": {
                "type": "string",
                "format": "",
                "description": ""
            },
            "matrix_res": {
                "type": "object",
                "format": "resource-matrix",
                "description": ""
            }
        }
    }
}

Sorry about this migration but my belief is that we do not have many flows that are that old