Skip to content

bug/2400: prevent folder creation skip when same path exists in another BU - #2533

Merged
JoernBerkefeld merged 4 commits into
developfrom
copilot/fix-asset-folder-creation
Mar 5, 2026
Merged

JoernBerkefeld merged 4 commits into
developfrom
copilot/fix-asset-folder-creation

Conversation

Copilot AI commented Mar 5, 2026 •

Copy link
Copy Markdown
Contributor

When deploying to a BU whose folder cache contains a same-path folder owned by a different BU (common when the SFMC API returns cross-BU folders), Folder.upsert would match that foreign folder via getFolderByPath (allowOtherBu=true default), skip creation, and leave the asset deployment referencing an invalid category ID — resulting in Unable to find a Category whose Id is 'XXXXX'.

Changes

  • lib/metadataTypes/Folder.js — Pass allowOtherBu = false to cache.getFolderByPath() in Folder.upsert. Only an exact Client.ID === currentMID match should be treated as "folder already exists"; a same-path folder from another BU must not suppress creation.

    // before
    const cachedVersion = cache.getFolderByPath(deployableMetadata.Path);
    
    // after — do not allow a cross-BU folder to be treated as already existing
    const cachedVersion = cache.getFolderByPath(deployableMetadata.Path, undefined, false);
  • test/type.folder.test.js + test fixtures — New test injects a Content Builder/testFolder_samePath folder with Client.ID=1111111 (foreign BU) into the retrieve response for testBU (MID=9999999), then deploys the same path. Without the fix: 0 created / 1 filtered. With fix: 1 created.

  • .husky/post-checkout, .husky/commit-msg — Replaced bash-specific [[ / IFS=$'\n' / array expansion with POSIX-compatible equivalents; husky runs hooks via sh -e, so these were failing silently in CI.

Issues

Original prompt

This section details on the original issue you should resolve

<issue_title>[BUG] Unable to create asset folder when same path exists in another business unit</issue_title>
<issue_description>### Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Devtools fails to deploy an asset when the target folder path already exists in a different Business Unit within the same instance

15:37:41 error:  ☇ error creating asset: TEST_ASSET:
15:37:41 error:    • Unable to find a Category whose Id is '23760')
Image

Expected Behavior

The asset should deploy successfully, and a new folder should be created in the target Business Unit, even if a folder with the same path exists elsewhere

Steps To Reproduce

  1. Open Marketing Cloud
  2. Go to BUSINESS_UNIT_1
  3. Go to Email Studio -> Email -> Content
  4. Create new folder
  5. Deploy a new asset to BUSINESS_UNIT_2 using mcdev deploy, with the same folder path as in the previous step
  6. See the error

Version

8.1.0

Environment

  • OS: Windows 11
  • Node: v24.11
  • npm: 11.6.1

Participation

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

Additional comments

No response</issue_description>

<agent_instructions>please read the comments to understand the issue better</agent_instructions>

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

@JoernBerkefeld possible Duplicate of #2323

@kacperkruger - trying to confirm if I'm on the right track: could it be that in your scenario you are trying to deploy to a child BU and the folder already exists on the parent bu?</comment_new>
<comment_new>@JoernBerkefeld

the issue only occurs when the folder already exists in child BU and try to deploy to a parent BU. when the deployment is done firrst to parent and then to child, everyhing works fine.

ahhhh, i tried to reproduce it the other day but i tried it the other way round. let me retry then. thank you for clarifying that @kacperkruger

side note: when you want to share logs, the log files in the logs/ folder often contain more info than what you see in the CLI.</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 issue with asset folder creation in different business units fix: prevent folder creation skip when same path exists in another BU Mar 5, 2026
@github-actions

github-actions Bot commented Mar 5, 2026 •

Copy link
Copy Markdown

Coverage Report

Commit:168060b
Base: develop@9cc40d9

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

@JoernBerkefeld JoernBerkefeld linked an issue Mar 5, 2026 that may be closed by this pull request
1 of 2 tasks
@JoernBerkefeld JoernBerkefeld added this to the 9.0.1 - folders milestone Mar 5, 2026
@JoernBerkefeld
JoernBerkefeld marked this pull request as ready for review March 5, 2026 20:19
@JoernBerkefeld
JoernBerkefeld merged commit fa01840 into develop Mar 5, 2026
12 checks passed
@JoernBerkefeld
JoernBerkefeld deleted the copilot/fix-asset-folder-creation branch March 5, 2026 20:20
@JoernBerkefeld JoernBerkefeld changed the title fix: prevent folder creation skip when same path exists in another BU bug/2400: prevent folder creation skip when same path exists in another BU Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants