Node Red returning nodes when accessing /flows in API

I tried to create a flow using the API. I submitted the data for a flow along with all nodes and their connections to POST /flows, but some error happened which caused the dashboard to show

Error adding flows

Cannot read properties of undefined (reading 'substring')

Now, when I access GET /flows it returns some flows that I already had implemented but the other problem is that it also returns a lot of nodes.
For example, this is also returned in the list:

{
        "id": "baba6511.294428",
        "type": "mqtt-broker",
        "name": "...",
        "broker": "...",
        "port": "2884",
        "clientid": "3",
        "usetls": false,
        "compatmode": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": ""
    },

When I try to access GET /flows/baba6511.294428, it returns a not found error which I don't get. Because if this is returned in the list, it should be an actual flow.
Any help is appreciated.

The /flows endpoint returns the complete flow configuration - its everything that is running, flows/subflows/nodes/config nodes/groups - everything.

The end point for an individual flow is /flow/:id not /flows/:id. See GET /flow/:id : Node-RED

Thank you for the quick respone.
The /flows/:id was a typo.
Is there a reason why I'm getting the error above or is there a way to revert it? Unfortunately I don't have a backup of the flows and I'm not sure whether restarting the service would help?

We'd need a lot more detail on what you actually did to understand why you're hitting an error.

If you posted a new set of flows to /flows that will have replaced everything that was there.

If you have not done anything post to /flows since, you may find a backup of your flows file in your user directory. If your normal flows file is called flows.json have a look for .flows.json.backup

The problem, I think, was that when I was sending the data in Python, the module didn't set the correct content type, i.e it did not send it as JSON.
When I send the exact same data in Postman as JSON everything works normally.

This is my local flows.json file:

[
    {
        "id": "f6f2187d.f17ca8",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "type": "tab",
        "label": "fdsfdsf",
        "id": "cad5fcf48ff2e192"
    },
    "id",
    "type",
    "name",
    "topic",
    "qos",
    "datatype",
    "broker",
    "nl",
    "rap",
    "x",
    "y",
    "wires",
    "id",
    "type",
    "name",
    "property",
    "action",
    "pretty",
    "x",
    "y",
    "wires",
    "id",
    "type",
    "name",
    "active",
    "tosidebar",
    "console",
    "tostatus",
    "complete",
    "targetType",
    "statusVal",
    "statusType",
    "x",
    "y",
    "wires",
    "id",
    "type",
    "name",
    "func",
    "outputs",
    "noerr",
    "initialize",
    "finalize",
    "libs",
    "x",
    "y",
    "wires",
    "id",
    "type",
    "name",
    "active",
    "tosidebar",
    "console",
    "tostatus",
    "complete",
    "statusVal",
    "statusType",
    "x",
    "y",
    "wires",
    "id",
    "type",
    "name",
    "topic",
    "qos",
    "retain",
    "respTopic",
    "contentType",
    "userProps",
    "correl",
    "expiry",
    "broker",
    "x",
    "y",
    "wires",
    "info"
]

Is there anything else that would help you in pointing me to where the problem lies and how to revert it?

It seems we need to add some additional validation to those routes to handle badly formatted requests.

Have you checked to see if the backup file exists? If not, then there's nothing else we can do.

If you're experimenting with programmatically changing things, you really should make sure you have a backup if/when it goes wrong.

Thank you for the help.

If anyone else stumbles upon this, I've fixed it by removing all unecessary inputs in the flows.json file i.e.

 "id",
    "type",
    "name",
    "topic",
    "qos",
    "datatype",
    "broker",
    "nl",
    "rap",
    "x",
    "y",
    "wires",
    "id",
    "type",
    "name",
    "property",
    "action",
    "pretty",
    "x",
    "y",
    "wires",
    "id",
    "type",
    "name",
    "active",
    "tosidebar",
    "console",
    "tostatus",
    "complete",
    "targetType",
    "statusVal",
    "statusType",
    "x",
    "y",
    "wires",
    "id",
    "type",
    "name",
    "func",
    "outputs",
    "noerr",
    "initialize",
    "finalize",
    "libs",
    "x",
    "y",
    "wires",
    "id",
    "type",
    "name",
    "active",
    "tosidebar",
    "console",
    "tostatus",
    "complete",
    "statusVal",
    "statusType",
    "x",
    "y",
    "wires",
    "id",
    "type",
    "name",
    "topic",
    "qos",
    "retain",
    "respTopic",
    "contentType",
    "userProps",
    "correl",
    "expiry",
    "broker",
    "x",
    "y",
    "wires",
    "info"

and then restarting node-red.