Troubleshooting
Why a Node-RED SMB write ignores a controller tag filename
Short answer
The write ignores the controller string because a literal-only filename field is stored as text and never evaluated against the message. Keep the CSV in one message property and the validated name in another, supply the name through the dynamic filename input the installed SMB node documents, and replace the writer if it offers no such input.

On this page
The write keeps landing under the name typed into the node's configuration dialog because a literal filename field is stored as text and never evaluated against the message — the controller string can be perfectly present in the flow and still change nothing. This is a binding fault, not a controller fault. The fix is to carry the validated name in its own message property, keep the CSV in another, and supply the name through the dynamic filename input the installed SMB node documents. If that node offers no such input, retyping the reference into the box will never work, and the writer itself has to change.
The binding decides the filename, not the controller read #
Three separate boundaries sit between the controller and the share:
- The controller driver reads the string and puts it into the message.
- The flow carries that value through conversion and transformation nodes.
- The write node consumes the value through the input its configuration points at.
Your symptom — a correct controller read that never reaches the filename — is a failure at the third boundary. The built-in Node-RED file nodes show what a working dynamic binding looks like: when their filename field is left empty, they take the name from msg.filename on each message. An SMB add-in defines its own interface, so its help decides whether it offers a literal box, a typed field with a message-property or expression option, or nothing dynamic at all. Those interfaces are not interchangeable. The payload half of a write node obeys the same rule, as the payload format the s7comm write node accepts from MQTT (article) shows: what the node consumes is what its configuration binds, not what happens to be in the message.
Trace where the string disappears #
Work from the middle of the flow outward:
- Inspect the complete message immediately after the controller read. Confirm the value arrives as a string, not a byte array, a status object or a driver structure. If it is structured, apply the driver's documented conversion to extract the text.
- Inspect the complete message immediately before the SMB write. Find both the generated CSV and the filename value. If the name existed before the CSV conversion and is gone after, a node rebuilt the message and dropped it — CSV conversion that replaces
msg.payloaddestroys any filename stored only inside that payload. - Compare the write node's configured input with the actual location of the value in the message. A matching label on screen proves nothing; the node must be pointed at the property that holds the name.
- Keep a known working literal filename as a baseline test. With the baseline writing successfully, any failure under the dynamic name is a binding or validation problem, not share connectivity.
Bind the name through the node's documented input #
- Open the installed SMB write node's help and record four things: how the filename input can be supplied, what data type it expects, the path format relative to the share, and the behavior when the file already exists.
- If the filename field has a type selector, set it to a message property and point it at
msg.filename. If it is a plain text box with no type option, it is literal-only — accept that and move to the next step instead of typing references into it. - If the installed writer is literal-only and dynamic naming is required, evaluate an integration that documents a filename message input. Two packages worth checking for that capability in their documentation are
node-red-contrib-smb, which accesses Windows shares over the SMBv2 protocol, andnode-red-contrib-filebrowser, which covers SMB/CIFS shares and FTP repositories. Verify the dynamic input in each package's own help before swapping the node in. - Keep the destination folder fixed in the flow configuration, so the controller string can only name a file inside the intended folder and can never redirect a write elsewhere on the share.
- Route validation failures and write errors to an output an operator can see. Reject the write rather than silently substituting an unrelated name.
A worked example with a validation test #
Suppose the controller supplies the batch label Batch 4471 as a string in msg.payload, and the flow must write it as a CSV named after that batch. An illustrative Function node between the controller read and the CSV builder:
// Illustrative Function node: derive a safe filename from the controller string
var raw = msg.payload; // expected type: string, example "Batch 4471"
if (typeof raw !== "string" || raw.trim().length === 0) {
return [null, { payload: "rejected: filename source is not a non-empty string" }];
}
var name = raw.trim().replace(/\s+/g, "_") + ".csv"; // example result "Batch_4471.csv"
if (name !== name.replace(/[^A-Za-z0-9._-]/g, "")) {
return [null, { payload: "rejected: characters the share does not allow: " + name }];
}
msg.filename = name; // type: string, read by the write node's dynamic input
return [msg, null];
The test that proves it, run with two inject messages:
- Inject
Batch 4471as a string. Output 1 carriesmsg.filenameequal toBatch_4471.csvand the original payload intact for the CSV builder. The write lands on the share under that name. - Inject
run/../escapeor an empty string. Output 2 fires with the rejection message and no write request is produced.
Because the name lives in msg.filename and the CSV overwrites msg.payload, the two values survive together through the conversion — provided no intermediate node rebuilds the message from scratch, which the pre-write debug check in the trace above catches.
When a valid name still lands wrong #
- Repeat behavior. A repeated controller value targets the same file again. Whether the writer overwrites, appends or rejects depends on its configuration: replacement suits a current snapshot, while separate production records need distinct names or explicit duplicate handling. Read the node's documented behavior and choose it deliberately.
- Timing. A filename fetched from a global or context store at write time can change while an earlier CSV is still moving through the flow. Capture the name into the message when the record is assembled, so name and content travel together.
- Permissions. The write runs under the account the Node-RED service runs as. Successful browsing from an operator desktop proves nothing about that account. Check the share permissions and the filesystem permissions on the destination, and note the pattern where creating a new file succeeds but replacing an existing one fails — that points to missing modify rights, not a filename problem.
Verify the fix end to end #
- Write once with the baseline literal filename to confirm share access and CSV output.
- Switch to the dynamic input, send one record with a known controller value, and inspect the final message: name and CSV content from the same record.
- Confirm the reported completion, then open the destination folder and check the actual filename and contents. Reaching the write node is not proof of remote storage.
- Repeat with a second, different controller value, then a duplicate value, then an invalid value. Expect a new file, the configured duplicate behavior, and a routed rejection respectively.
Questions asked
Can I type the message property reference into the filename box?
No. A plain text filename field stores whatever you type as literal text, so the share ends up with a file literally named after your reference. If the field has a type selector, switch it to a message property there. If it does not, the field is literal-only and the writer has to change.
Which message property should carry the filename?
Use msg.filename, the property the built-in file nodes read when their filename field is left empty. It keeps the name separate from msg.payload, which the CSV builder overwrites. The installed SMB node's help is the final word: bind whatever property that node actually reads, and confirm it in a debug message before the write.
Why does a write that succeeds from a desktop fail from the gateway?
Browsing a share interactively proves nothing about that runtime account. Check both permission layers: the share permissions and the filesystem permissions. A pattern where creating a new file succeeds but replacing an existing one fails points to missing modify rights.
Should the controller string include the file extension?
Decide one rule and enforce it in the flow. Supplying only the base name from the controller and appending the extension in the flow is the cleaner choice: the flow controls the format, so a controller value that already ends in the extension cannot produce a double-suffixed file, and a format change touches one node.

