I need to copy/paste a flow that contains a subflow. However, when I do this, nodered creates an identical subflow but appends (2) or (3) or (4), etc. to the end of the subflow name. So far I determined a very basic test subflow does not behave like this, but once I include an mqtt node, I get this behavior. I have an example flow below.
Take the example flow, import it, then import it again and you should find yourself with a subflow called 'test subflow' and another one called 'test subflow (2)'. You can try just deleting the mqtt node and then repeating this process and you will not get 'test subflow (2)', you will only have 'test subflow'.
I am seeing that node-red automatically renames the subflow and changes the id of the subflow. I'm just not sure what triggers the conflict when it imports it. Apparently having an mqtt node does this, but just having the function node does not.
*note: this flow does not really do anything, it's just a quick way to demonstrate the issue. thanks for your help!
[{"id":"df115b21.a9c4f8","type":"subflow","name":"test subflow","info":"","category":"","in":[{"x":562.9999942779541,"y":249.0000114440918,"wires":[{"id":"388c98ef.3128e8"}]}],"out":[{"x":847.9999980926514,"y":245.99999618530273,"wires":[{"id":"388c98ef.3128e8","port":0}]}],"env":[]},{"id":"ad02fcde.0f788","type":"comment","z":"df115b21.a9c4f8","name":"test subflow import","info":"test subflow import","x":738.0234298706055,"y":127.05468368530273,"wires":[]},{"id":"388c98ef.3128e8","type":"function","z":"df115b21.a9c4f8","name":"hello","func":"msg.payload = \"hello\"\nreturn msg;","outputs":1,"noerr":0,"x":705.7734375,"y":246.203125,"wires":[[]]},{"id":"5b73054.8c7c8fc","type":"mqtt in","z":"df115b21.a9c4f8","name":"","topic":"test","qos":"2","datatype":"auto","broker":"547471b5.d339","x":544.7734603881836,"y":339.32031631469727,"wires":[["388c98ef.3128e8"]]},{"id":"547471b5.d339","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"dc3259b7.f5bd38","type":"tab","label":"test main flow","disabled":false,"info":""},{"id":"5073cfef.7fabf","type":"subflow:df115b21.a9c4f8","z":"dc3259b7.f5bd38","name":"","env":[],"x":861.7734375,"y":198.15625,"wires":[["94067309.e00a"]]},{"id":"94d27430.3f8208","type":"inject","z":"dc3259b7.f5bd38","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":660.7734298706055,"y":198.56249809265137,"wires":[["5073cfef.7fabf"]]},{"id":"94067309.e00a","type":"debug","z":"dc3259b7.f5bd38","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1095.773494720459,"y":195.3437557220459,"wires":[]}]
I wanted to write this post as a speficific feature request, but my original question about this can be found here: Why does importing a clipboard with a subflow create a "new" identical but renamed subflow