Comfy-Org / Comfy-Org/ComfyUI

String nodes with multiline true seem to modify the actual string

Open
#2,585 6 comments 0 reactions 0 assignees View on GitHub
User Support
Dominant language
Python
Stars
133k
Forks
15.7k
Avg merge
1d 6h
Merged PRs (30d)
155

Description

Hello, when trying to use any node with a multiline string, it seems to mutate the actual string, specifically for my case, it is stripping out the curly braces.

# Background:

I'm trying to setup a node that takes in some headers. Headers have the JSON format ie: {"foo": "bar"}

If I use a primitive (or Simple String from Use Everywhere, the output is as expected: {"foo": "bar"}

I want to the node to display a bigger text, in a way that is readable to go through and edit the potentially long json string, so I think using string with multiline will be better suited. But if I try to use a node that has the multiline set to true, it seems to strip out all the curly braces, which results in the following: "foo": "bar"

This is rather odd as a string is a string, no need to modify it in any way. I tried multiple custom nodes, even set one up myself, thinking they were changing the format, but it turns out it must be ComfyUI, since the code is simply returning the string, and not doing anything to it:

```
class SimpleStringBox(Base):
OUTPUT_NODE = False
@classmethod
def INPUT_TYPES(s):
return {"required":{ "string": ("STRING", {"default": "",
"multiline": True
}) }}
RETURN_TYPES = ("STRING",)

def func(self,string):
return (string,)
```

See the following setup:
![Screenshot 2024-01-18 203445](https://github.com/comfyanonymous/ComfyUI/assets/867047/8d538ed4-9715-44fb-bf92-d77b3a32d823)

# Solution
I would like to see the multiline: true string output exactly as is, such as when the option is set to false.

# Reproduction
To be absolutely sure, I made the following:
```
class SimpleStringBoxTrue(Base):
OUTPUT_NODE = False
@classmethod
def INPUT_TYPES(s):
return {"required":{ "string": ("STRING", {"default": "",
"multiline": True
}) }}
RETURN_TYPES = ("STRING",)

def func(self,string):
return (string,)

class SimpleStringBoxFalse(Base):
OUTPUT_NODE = False
@classmethod
def INPUT_TYPES(s):
return {"required":{ "string": ("STRING", {"default": "",
"multiline": False
}) }}
RETURN_TYPES = ("STRING",)

def func(self,string):
return (string,)

# A dictionary that contains all nodes you want to export with their names
# NOTE: names should be globally unique
NODE_CLASS_MAPPINGS = {
"SimpleStringBoxTrue": SimpleStringBoxTrue,
"SimpleStringBoxFalse": SimpleStringBoxFalse
}

# A dictionary that contains the friendly/humanly readable titles for the nodes
NODE_DISPLAY_NAME_MAPPINGS = {
"SimpleStringBoxTrue": "Simple String Multiline Box",
"SimpleStringBoxFalse": "Simple String Multiline Box",

}
```
And got the same result:
![Screenshot 2024-01-18 204609](https://github.com/comfyanonymous/ComfyUI/assets/867047/66824edf-38da-4d07-91cc-db93d560be35)

Thank you.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.