Skip to content

bug/1781: fix folder path when folder name contains slash character - #2534

Merged
JoernBerkefeld merged 5 commits into
developfrom
copilot/fix-folder-path-slash-issue
Mar 6, 2026
Merged

JoernBerkefeld merged 5 commits into
developfrom
copilot/fix-folder-path-slash-issue

Conversation

Copilot AI commented Mar 5, 2026 •

Copy link
Copy Markdown
Contributor

SFMC's SOAP DataFolder create/update API silently strips / from folder names, making it unsuitable for asset and asset-shared folder types. The /asset/v1/content/categories REST endpoint preserves them. This PR routes those two types through REST (same as cloudpages already was) and replaces the now-incorrect script-based slash-folder tests with asset-based equivalents.

Changes

lib/metadataTypes/definitions/Folder.definition.js

  • deployFolderTypesAssetRest: ['cloudpages'] → ['cloudpages', 'asset', 'asset-shared']
  • All create/update calls for these folder types now hit PUT/POST /asset/v1/content/categories

test/type.folder.test.js

  • Removed script-based retrieve + deploy slash-folder tests (scripts use SOAP which strips /, so those tests were validating incorrect behavior)
  • Updated folder-deploy-slash and folder-deploy-samepath assertions: SOAP callout checks → REST callout checks
  • Added retrieve test: asset in SFMC folder bla/blub → r__folder_Path stored as "Content Builder/bla∕blub" (U+2215 escape)
  • Added deploy test: asset with r__folder_Path: "Content Builder/bla∕blub" triggers REST folder create with name: "bla/blub" (real slash, not escape char)

New test fixtures

File Purpose
asset/v1/content/categories/post-response.json Mock REST folder create response
asset/v1/content/assets/post-response-key=test_slash.json Mock asset create response
asset/v1/content/assets/16992/get-response.json Mock individual GET for test_slash
asset/v1/content/assets/query/+post-response-…-slashfolder.json Asset query variant including test_slash
dataFolder/+retrieve-ContentTypeINasset,asset-shared,cloudpages-slashfolder-response.xml Folder SOAP variant with bla/blub (real slash in <Name>)
asset-slashfolder-deploy/block/test_slash.* Deploy fixtures for new asset deploy test

Deleted

All script-slashfolder fixtures (script-slashfolder-deploy/, script/get_slashfolder-expected.*, +retrieve-ContentType=ssjsactivity-slashfolder-response.xml, +get-slashfolder-response.json).

Documentation

deployFolderTypesAssetRest in Folder.definition.js now covers asset and asset-shared in addition to cloudpages. Folders of these types are created/updated via POST/PUT /asset/v1/content/categories. The ∕ (U+2215) escape in r__folder_Path is preserved for retrieve; deploy unescapes to the real / before sending to the API.

Release details

Checklist

Before merge

  • Wiki updated with info in ticket listed under Documentation
  • ran npm run prepare-release (which runs npm audit fix, npm run lint-ts, npm run lint:fix, git add, git commit)
  • pushed potential changes made by prepare-release

After merge

  • merged all dependabot PRs that target main branch
  • updated bug template to include the new version
  • updated .mcdevrc for tests to the new version
  • ran npm run version:major/minor/patch
  • pushed version-prep commits
  • merged main branch into develop branch
  • closed GitHub milestone
  • created new GitHub Release
Original prompt

This section details on the original issue you should resolve

<issue_title>[BUG] Wrong folder path when folder name contains the / (slash) character</issue_title>
<issue_description>### Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Content Builder allows you to create folders and include the / (slash) character in its name. When retrieving assets from a folder that has this character in the name it will make the folder path as if it were two separated folders. This causes issues, for example, if we want to deploy to another business unit since a new folder will be created instead of having only the original folder.

Content Builder:

image

mcdev - r__folder_Path :

image

Deploy to new BU:

image

Expected Behavior

If folder name contains a slash character it should keep the folder name instead of creating a new folder.

Steps To Reproduce

  1. Go to Content Builder and create a new folder with / character. Create an asset inside this folder.
  2. Run the mcdev retrieve .... -m asset
  3. Check r__folder_Path in the file created in the folder.
  4. Deploy this asset to different Business Unit
  5. Check folder structure in the Business Unit where the file was deployed

Version

7.4.4

Environment

  • OS: Windows 11
  • Node: v21.4.0
  • npm: 10.5.0

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

No response</issue_description>

<agent_instructions>Prefix the pr title with "bug/1781:"</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@JoernBerkefeld We probably need to replace the slash with a placeholder to make it work.

Let's pick one of these:

https://stackoverflow.com/a/75007033/818732</comment_new>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix wrong folder path when folder name contains slash character bug/1781: fix folder path when folder name contains slash character Mar 5, 2026
@JoernBerkefeld JoernBerkefeld added this to the 9.0.1 - folders milestone Mar 5, 2026
@JoernBerkefeld JoernBerkefeld linked an issue Mar 5, 2026 that may be closed by this pull request
1 of 2 tasks
@github-actions

github-actions Bot commented Mar 5, 2026 •

Copy link
Copy Markdown

Coverage Report

Commit:c5beb7d
Base: develop@fa01840

Type Base This PR
Total Statements Coverage  71%  71.11%  (+0.11%)
Total Branches Coverage  70.8%  70.86%  (+0.06%)
Total Functions Coverage  83.71%  83.71%  (+0%)
Total Lines Coverage  71%  71.11%  (+0.11%)
Details (changed files):
File Statements Branches Functions Lines

@JoernBerkefeld JoernBerkefeld added bug Something isn't working c/asset COMPONENT labels Mar 5, 2026

@JoernBerkefeld JoernBerkefeld left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot please have a look at my review except for the the one on asset.js which need to be tested by me

` %%= ContentBlockByName("${
json.folder
.split('/')
.map((s) => s.replaceAll(Util.folderNameSlashEscapeChar, '/'))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to be tested how this really works. We might need to keep the forward sladh in that situation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood — skipping this one for you to test. The current code unescapes ∕ → / per path segment before building the ContentBlockByName hint string, so the displayed path would use the real slash matching what SFMC expects. Happy to adjust once you've verified the actual behavior.

Comment thread lib/metadataTypes/Folder.js Resolved
Comment thread lib/util/util.js Resolved
"description": "created on deploy",
"key": "testNew_slashFolderScript",
"name": "testNew_slashFolderScript",
"r__folder_Path": "Scripts/Headers\u2215Folders"

@JoernBerkefeld JoernBerkefeld Mar 5, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not wanted like that. The unicode char needs to be rendered

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b8f0916 — the test fixture now contains the actual rendered ∕ character (U+2215, UTF-8 bytes e2 88 95) rather than the \u2215 JSON escape sequence, matching how fs.writeJSON writes the character in real retrieved files.

@JoernBerkefeld
JoernBerkefeld marked this pull request as ready for review March 5, 2026 22:36
…oyFolderTypesAssetRest

Co-authored-by: JoernBerkefeld <[email protected]>
Copilot AI changed the title bug/1781: fix folder path when folder name contains slash character fix(folder): use REST endpoint for asset/asset-shared folder create/update; replace script slash-folder tests with asset Mar 6, 2026
@JoernBerkefeld JoernBerkefeld changed the title fix(folder): use REST endpoint for asset/asset-shared folder create/update; replace script slash-folder tests with asset bug/1781: fix folder path when folder name contains slash character Mar 6, 2026
@JoernBerkefeld
JoernBerkefeld merged commit 00e6de6 into develop Mar 6, 2026
18 of 19 checks passed
@JoernBerkefeld
JoernBerkefeld deleted the copilot/fix-folder-path-slash-issue branch March 6, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working c/asset COMPONENT c/folder COMPONENT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Wrong folder path when folder name contains the / (slash) character

2 participants