Skip to content

fix(folder): support subfolder paths in move-emails via getFolderIdByName path resolution - #71

Closed
rafaga2469 wants to merge 3 commits into
ryaker:mainfrom
rafaga2469:fix/subfolder-move-emails
Closed

rafaga2469 wants to merge 3 commits into
ryaker:mainfrom
rafaga2469:fix/subfolder-move-emails

Conversation

@rafaga2469

@rafaga2469 rafaga2469 commented Jul 28, 2026 •

Copy link
Copy Markdown

Linked Issues

Closes #67
Closes #68

Summary

  • move-emails fails when targeting subfolders (e.g. Tramite/REQ-104951) because getFolderIdByName() only searches top-level folders via me/mailFolders?$filter=displayName eq '{name}'
  • This PR enhances getFolderIdByName() to split folder paths on / and traverse the Graph folder hierarchy level-by-level using me/mailFolders/{parentId}/childFolders endpoints
  • Backwards compatible: flat folder names (no /) use the identical code path as before — zero blast radius for existing callers

Changes

File Change
email/folder-utils.js Added resolveSegmentInParent() helper; rewrote getFolderIdByName() with path splitting, empty segment filtering, and short-circuit on null
test/email/folder-utils.test.js Added 11 unit test cases covering all 8 spec scenarios (two-level, three-level, flat compat, case-insensitive, non-existent, empty segments, API error, helper direct tests)
utils/mock-data.js Added CHILD_FOLDERS mock map and childFolders branch for test-mode server
auth/token-storage.js Restored constructor warning text to match existing test expectation (pre-existing mismatch found during full-suite verification)

How It Works

getFolderIdByName("Tramite/REQ-104951")
  -> split('/') -> ["Tramite", "REQ-104951"]
  -> segment[0]: resolveSegmentInParent(null, "Tramite")
      GET me/mailFolders?$filter=displayName eq 'Tramite'
      -> exact match -> parentId = "tramite-id"
  -> segment[1]: resolveSegmentInParent("tramite-id", "REQ-104951")
      GET me/mailFolders/tramite-id/childFolders?$filter=displayName eq 'REQ-104951'
      -> exact match -> leafId = "req-104951-id"
  -> return "req-104951-id"

Each segment has a case-insensitive fallback (fetch all, match by toLowerCase()) matching the existing top-level pattern.

Test Plan

  • All 142 tests pass (npm test) — 24 in folder-utils, 118 across other modules
  • 11 new tests cover: two-level path, three-level path, flat backwards compat, case-insensitive segments, non-existent segment (short-circuit), non-existent top-level, empty segments (//), all-empty path, API error mid-traversal, helper exact match, helper case-insensitive fallback
  • Zero regressions in existing tests
  • Backwards compatibility verified: flat folder names use identical code path

Known Limitations

  • Folder names containing a literal / in their display name are not supported — / is treated exclusively as a path separator. This is documented in the spec and is extremely rare in practice.
  • Deeply nested paths (5+ levels) add sequential API calls. Typical mailbox depth is 2-3 levels, so this is acceptable for per-request operations.

Contributor Checklist

  • Conventional commit format (fix(folder): ...)
  • No Co-Authored-By trailers
  • Tests pass locally
  • Backwards compatible

Summary by CodeRabbit

  • New Features
    • Email moves now support slash-delimited nested folder targets (multi-level), with improved case-insensitive matching and robust handling of extra separators.
    • The application now loads environment variables from a local .env file at startup.
  • Bug Fixes
    • Moving emails to nested folders now consistently resolves the correct destination.
  • Documentation
    • Added and updated OpenSpec specifications, proposals, design notes, and verification records for folder-path handling.
    • Updated generated Skill Registry documentation.

…h resolution

Enhance getFolderIdByName() to split folder names on '/' and traverse
the Graph folder hierarchy level-by-level using childFolders endpoints.
Backwards compatible: flat folder names (no '/') use identical code path.

- Add resolveSegmentInParent() helper for per-segment exact + case-insensitive fallback
- Rewrite getFolderIdByName() with path splitting, empty segment filtering, short-circuit on null
- Add 11 unit tests covering all 8 spec scenarios (142/142 total passing)
- Extend mock-data.js with CHILD_FOLDERS map for test-mode server
- Restore token-storage.js warning text to match existing test expectation
- Add OpenSpec SDD artifacts (proposal, spec, design, tasks, verify, archive)

Closes ryaker#67, closes ryaker#68
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@codeant-ai

codeant-ai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

User does not have a PR Review subscription.

Go to Team management and add this email to the PR Review subscription.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6058b4e0-6a9f-4f9a-969f-0d07c47fe2c9

📥 Commits

Reviewing files that changed from the base of the PR and between 8a2c4c8 and c0a2ac7.

📒 Files selected for processing (1)
  • email/folder-utils.js

📝 Walkthrough

Walkthrough

The change adds hierarchical Outlook folder-path resolution with exact and case-insensitive segment matching across child folders. It also adds tests, mocks, specifications, verification reports, environment loading, configuration updates, a dependency update, and skill registry metadata.

Changes

Folder resolution

Layer / File(s) Summary
Folder resolution contract and design
openspec/changes/archive/2026-07-28-fix-subfolder-move-emails/*, openspec/specs/email/spec.md
Documents slash-delimited traversal, flat-name compatibility, fallback matching, error handling, and validation requirements.
Hierarchical folder lookup implementation
email/folder-utils.js, utils/mock-data.js
Resolves folder segments through top-level and child-folder Graph queries, with mock child-folder responses.
Path resolution tests and verification
test/email/folder-utils.test.js, openspec/changes/archive/2026-07-28-fix-subfolder-move-emails/*
Tests multi-level paths, fallback matching, empty segments, failures, short-circuiting, and helper behavior; records verification results.

Project setup and metadata

Layer / File(s) Summary
Runtime and development setup
index.js, auth/token-storage.js, package.json, openspec/config.yaml
Loads .env values, updates the token configuration warning, upgrades the inspector dependency, and adds OpenSpec workflow configuration.
Skill registry metadata
.atl/skill-registry.md, .atl/.skill-registry.cache.json
Updates generated skill registry metadata and its fingerprint.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Sequence Diagram(s)

sequenceDiagram
  participant MoveEmails
  participant FolderUtils
  participant GraphAPI
  MoveEmails->>FolderUtils: resolve target folder path
  FolderUtils->>GraphAPI: query top-level folder segment
  GraphAPI-->>FolderUtils: parent folder ID
  FolderUtils->>GraphAPI: query child-folder segment
  GraphAPI-->>FolderUtils: target folder ID
  FolderUtils-->>MoveEmails: folder ID or null
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes unrelated env bootstrapping and a devDependency bump that are not required for subfolder path resolution. Move the dotenv startup change and dependency upgrade into separate PRs, unless they are required for the linked folder-resolution fix.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is specific, concise, and accurately reflects the main change: subfolder path resolution for move-emails.
Linked Issues check ✅ Passed The PR implements path-based folder resolution through childFolders and preserves flat-folder behavior, matching the linked issues.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.atl/skill-registry.md:
- Around line 4-5: Remove the machine-specific user-level path and username from
the skill registry, including the entries covered by lines 9-82. Replace them
with portable skill identifiers or project-relative paths; if the registry must
represent user-level skills, generate that data outside version control.

In `@auth/token-storage.js`:
- Line 31: Update the warning in TokenStorage to reference both supported
credential variable pairs, MS_CLIENT_ID/MS_CLIENT_SECRET and
OUTLOOK_CLIENT_ID/OUTLOOK_CLIENT_SECRET, so it accurately reflects fallback
configuration options. Update the corresponding exact-string test to match the
revised warning text.

In `@email/folder-utils.js`:
- Around line 69-105: Update resolveSegmentInParent to escape apostrophes in
segment by replacing each single quote with two single quotes before
constructing the OData displayName filter. Use the escaped value only for the
exact-match request, while preserving the existing case-insensitive fallback and
original segment comparison behavior.

In `@openspec/specs/email/spec.md`:
- Around line 9-11: Update the Path Resolution requirement for getFolderIdByName
and resolveSegmentInParent to specify pagination when folder lookups exceed the
initial 100 results, covering both top-level and childFolders queries;
alternatively, explicitly document the $top: 100 limitation if that is the
intended contract.
- Around line 71-79: Update resolveSegmentInParent() so folder-name segments are
escaped as valid OData string literals before being interpolated into the
displayName filter, including apostrophes such as in “Bob’s”. Preserve
slash-based path interpretation and add or update the specification scenario to
document and test the chosen behavior.

In `@package.json`:
- Line 34: Update the package.json engines.node constraint to require Node.js
>=22.7.5, matching the `@modelcontextprotocol/inspector` dependency version, while
preserving the existing inspector dependency declaration.

In `@utils/mock-data.js`:
- Around line 123-144: Update the mock mail-folder response logic in the path
resolver to honor queryParams.$filter when selecting top-level folders,
returning only the matching folder instead of the entire collection. Extend
CHILD_FOLDERS with the documented tramite hierarchy, including the REQ-104951
child, so Tramite/REQ-104951 resolution works in test mode while preserving
existing inbox behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 60396948-a954-4bef-8af7-826e376652d2

📥 Commits

Reviewing files that changed from the base of the PR and between 95d6ff2 and 8a2c4c8.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (17)
  • .atl/.skill-registry.cache.json
  • .atl/skill-registry.md
  • auth/token-storage.js
  • email/folder-utils.js
  • index.js
  • openspec/changes/archive/2026-07-28-fix-subfolder-move-emails/archive-report.md
  • openspec/changes/archive/2026-07-28-fix-subfolder-move-emails/design.md
  • openspec/changes/archive/2026-07-28-fix-subfolder-move-emails/exploration.md
  • openspec/changes/archive/2026-07-28-fix-subfolder-move-emails/proposal.md
  • openspec/changes/archive/2026-07-28-fix-subfolder-move-emails/specs/email/spec.md
  • openspec/changes/archive/2026-07-28-fix-subfolder-move-emails/tasks.md
  • openspec/changes/archive/2026-07-28-fix-subfolder-move-emails/verify-report.md
  • openspec/config.yaml
  • openspec/specs/email/spec.md
  • package.json
  • test/email/folder-utils.test.js
  • utils/mock-data.js

Comment thread .atl/skill-registry.md
Comment on lines +4 to +5
Scope: user-level skills (D:\Usuarios\ricardo.pinto\.config\opencode\skills)
Project-level skills: none detected

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Do not commit machine-specific user-level paths.

The registry exposes the local username ricardo.pinto and hard-codes Windows paths that will be invalid for other developers and CI. Store portable skill identifiers/project-relative paths, or generate user-level registry data outside version control.

Also applies to: 9-82

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.atl/skill-registry.md around lines 4 - 5, Remove the machine-specific
user-level path and username from the skill registry, including the entries
covered by lines 9-82. Replace them with portable skill identifiers or
project-relative paths; if the registry must represent user-level skills,
generate that data outside version control.

Comment thread auth/token-storage.js

if (!this.config.clientId || !this.config.clientSecret) {
console.warn("TokenStorage: Client ID or Secret is not configured (checked MS_CLIENT_ID/OUTLOOK_CLIENT_ID). Token refresh will fail.");
console.warn("TokenStorage: MS_CLIENT_ID or MS_CLIENT_SECRET is not configured. Token operations might fail.");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Keep the warning consistent with supported credential fallbacks.

TokenStorage also accepts OUTLOOK_CLIENT_ID and OUTLOOK_CLIENT_SECRET at Lines 11-13, but this warning names only MS_*. When fallback credentials are incomplete, the message points users toward the wrong variable names. Update the warning and its exact-string test accordingly.

Proposed wording
-      console.warn("TokenStorage: MS_CLIENT_ID or MS_CLIENT_SECRET is not configured. Token operations might fail.");
+      console.warn("TokenStorage: no supported client ID/secret pair is configured (MS_CLIENT_ID/MS_CLIENT_SECRET or OUTLOOK_CLIENT_ID/OUTLOOK_CLIENT_SECRET). Token operations might fail.");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console.warn("TokenStorage: MS_CLIENT_ID or MS_CLIENT_SECRET is not configured. Token operations might fail.");
console.warn("TokenStorage: no supported client ID/secret pair is configured (MS_CLIENT_ID/MS_CLIENT_SECRET or OUTLOOK_CLIENT_ID/OUTLOOK_CLIENT_SECRET). Token operations might fail.");
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@auth/token-storage.js` at line 31, Update the warning in TokenStorage to
reference both supported credential variable pairs,
MS_CLIENT_ID/MS_CLIENT_SECRET and OUTLOOK_CLIENT_ID/OUTLOOK_CLIENT_SECRET, so it
accurately reflects fallback configuration options. Update the corresponding
exact-string test to match the revised warning text.

Comment thread email/folder-utils.js
Comment on lines +9 to +11
### Requirement: Path Resolution

`getFolderIdByName()` MUST resolve folder paths separated by `/` by traversing the folder hierarchy level by level.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Files:"
git ls-files | rg '(^openspec/specs/email/spec\.md$|email/folder-utils\.js$|email/.*test.*\.js$|test.*email.*\.js$)' || true

echo
echo "spec.md section:"
if [ -f openspec/specs/email/spec.md ]; then
  cat -n openspec/specs/email/spec.md
fi

echo
echo "folder-utils outline:"
if [ -f email/folder-utils.js ]; then
  ast-grep outline email/folder-utils.js || true
  echo "--- folder-utils.js ---"
  cat -n email/folder-utils.js
fi

Repository: ryaker/outlook-mcp

Length of output: 11190


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Search for getFolderIdByName usages/tests/definitions:"
rg -n "getFolderIdByName|nextLink|odata\.nextLink|\\$top|/pages/|folder-utils" . --glob '!node_modules' --glob '!dist' --glob '!build' || true

echo
echo "Diff stat/name-only if available:"
git diff --stat || true
git diff -- openspec/specs/email/spec.md email/folder-utils.js || true

Repository: ryaker/outlook-mcp

Length of output: 247


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Search for getFolderIdByName usages/tests/definitions:"
rg -n "getFolderIdByName|nextLink|odata\.nextLink|\$top|childFolders|folder-utils" . --glob '!node_modules' --glob '!dist' --glob '!build' || true

echo
echo "Tests around folder resolution:"
if [ -f test/email/folder-utils.test.js ]; then
  cat -n test/email/folder-utils.test.js
fi
echo
if [ -f test/email/list.test.js ]; then
  cat -n test/email/list.test.js
fi

Repository: ryaker/outlook-mcp

Length of output: 50374


Specify pagination for folder lookups.

resolveSegmentInParent() limits the case-insensitive fallback to $top: 100, so a valid segment beyond the first page is not resolvable for both top-level and childFolders lookups. Contract this as paginated or add a limitation that $top: 100 is sufficient.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@openspec/specs/email/spec.md` around lines 9 - 11, Update the Path Resolution
requirement for getFolderIdByName and resolveSegmentInParent to specify
pagination when folder lookups exceed the initial 100 results, covering both
top-level and childFolders queries; alternatively, explicitly document the $top:
100 limitation if that is the intended contract.

Comment thread openspec/specs/email/spec.md
Comment thread package.json
},
"devDependencies": {
"@modelcontextprotocol/inspector": "^0.10.2",
"@modelcontextprotocol/inspector": "^0.22.0",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n '"`@modelcontextprotocol/inspector`"|inspector' \
  package.json package-lock.json npm-shrinkwrap.json 2>/dev/null || true

npm view `@modelcontextprotocol/inspector`@0.22.0 version peerDependencies engines

Repository: ryaker/outlook-mcp

Length of output: 2353


🌐 Web query:

@modelcontextprotocol/inspector 0.22.0 breaking changes package entry points CLI

💡 Result:

There are no intended breaking changes regarding package entry points or CLI functionality in version 0.22.0 of @modelcontextprotocol/inspector; the release was primarily a version synchronization of the monorepo packages [1][2]. However, users of the inspector CLI encountered a persistent functional defect (ERR_MODULE_NOT_FOUND) introduced in version 0.17.0 and remaining in 0.22.0 [3]. This issue was caused by an attempt to import the CLI's package.json file, which was excluded from the published npm tarball because it was missing from the root package's files array [4][3]. Key details regarding this state include: 1. Scope of Impact: The CLI functionality via npx @modelcontextprotocol/inspector --cli remained broken in version 0.22.0 due to this packaging configuration error [4][3]. 2. Resolution: A fix was identified (PR #1506) to include cli/package.json in the files array of the root package.json, ensuring the file is included in future published npm tarballs [4][3]. 3. CLI Evolution: While not a breaking change in 0.22.0, the project has been actively planning for a CLI v2, which intends to introduce mcp as a primary command entry point that functions similarly to the existing launcher dispatch logic [5]. Official documentation and releases confirm that 0.22.0 was intended as a version bump without functional feature changes to the CLI [2].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "node constraint files:"
for f in package.json engines.json .node-version .tool-versions nvmrc Dockerfile docker-compose.yml; do
  [ -e "$f" ] && echo "--- $f ---" && sed -n '1,160p' "$f"
done

echo
echo "inspector CLI entrypoint declarations:"
node - <<'JS'
const fs = require('fs');
for (const name of ['node_modules/@modelcontextprotocol/inspector/package.json','node_modules/@modelcontextprotocol/inspector-cli/package.json']) {
  if (fs.existsSync(name)) {
    const p = JSON.parse(fs.readFileSync(name, 'utf8'));
    console.log(name);
    console.log({ bin: p.bin, main: p.main, type: p.type, files: p.files });
  }
}
JS

Repository: ryaker/outlook-mcp

Length of output: 1223


Set the Node constraint for the upgraded inspector.

package.json still declares engines.node: ">=14.0.0", while @modelcontextprotocol/inspector@0.22.0 requires node: ">=22.7.5". This can be caught by future CI or local usage before running npm run inspect. Update engines.node or add an explicit Node 22.7.5 requirement.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@package.json` at line 34, Update the package.json engines.node constraint to
require Node.js >=22.7.5, matching the `@modelcontextprotocol/inspector`
dependency version, while preserving the existing inspector dependency
declaration.

Comment thread utils/mock-data.js
Comment on lines +123 to +144
// Child folder lookup support for path-style folder references
const CHILD_FOLDERS = {
"inbox": [
{ id: "inbox-child", displayName: "InboxChild" }
]
};

if (path.includes('childFolders')) {
const parentId = path.split('/').find((segment, index, parts) => {
return parts[index - 1] === 'mailFolders' && parts[index + 1] === 'childFolders';
});
return { value: CHILD_FOLDERS[parentId] || [] };
}

// Simulate a mail folders response
return {
value: [
{ id: "inbox", displayName: "Inbox" },
{ id: "drafts", displayName: "Drafts" },
{ id: "sentItems", displayName: "Sent Items" },
{ id: "deleteditems", displayName: "Deleted Items" }
{ id: "deleteditems", displayName: "Deleted Items" },
{ id: "tramite", displayName: "Tramite" }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Make test-mode responses honor $filter and model the documented hierarchy.

resolveSegmentInParent() treats any non-empty response as an exact match, but this mock returns every top-level folder regardless of queryParams.$filter; Tramite therefore resolves to Inbox. It also has no tramite children, so the documented Tramite/REQ-104951 test-mode flow cannot work.

Proposed fix
+      const TOP_LEVEL_FOLDERS = [
+        { id: "inbox", displayName: "Inbox" },
+        { id: "drafts", displayName: "Drafts" },
+        { id: "sentItems", displayName: "Sent Items" },
+        { id: "deleteditems", displayName: "Deleted Items" },
+        { id: "tramite", displayName: "Tramite" }
+      ];
       const CHILD_FOLDERS = {
         "inbox": [
           { id: "inbox-child", displayName: "InboxChild" }
+        ],
+        "tramite": [
+          { id: "req-104951-id", displayName: "REQ-104951" }
         ]
       };
 
-      if (path.includes('childFolders')) {
+      const folders = path.includes('childFolders')
+        ? (() => {
           const parentId = path.split('/').find((segment, index, parts) => {
             return parts[index - 1] === 'mailFolders' && parts[index + 1] === 'childFolders';
           });
-        return { value: CHILD_FOLDERS[parentId] || [] };
-      }
-
-      // Simulate a mail folders response
-      return {
-        value: [
-          { id: "inbox", displayName: "Inbox" },
-          { id: "drafts", displayName: "Drafts" },
-          { id: "sentItems", displayName: "Sent Items" },
-          { id: "deleteditems", displayName: "Deleted Items" },
-          { id: "tramite", displayName: "Tramite" }
-        ]
-      };
+          return CHILD_FOLDERS[parentId] || [];
+        })()
+        : TOP_LEVEL_FOLDERS;
+      const requestedName = queryParams.$filter
+        ?.match(/^displayName eq '((?:''|[^'])*)'$/)?.[1]
+        ?.replace(/''/g, "'");
+      return {
+        value: requestedName
+          ? folders.filter(folder => folder.displayName === requestedName)
+          : folders
+      };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Child folder lookup support for path-style folder references
const CHILD_FOLDERS = {
"inbox": [
{ id: "inbox-child", displayName: "InboxChild" }
]
};
if (path.includes('childFolders')) {
const parentId = path.split('/').find((segment, index, parts) => {
return parts[index - 1] === 'mailFolders' && parts[index + 1] === 'childFolders';
});
return { value: CHILD_FOLDERS[parentId] || [] };
}
// Simulate a mail folders response
return {
value: [
{ id: "inbox", displayName: "Inbox" },
{ id: "drafts", displayName: "Drafts" },
{ id: "sentItems", displayName: "Sent Items" },
{ id: "deleteditems", displayName: "Deleted Items" }
{ id: "deleteditems", displayName: "Deleted Items" },
{ id: "tramite", displayName: "Tramite" }
// Child folder lookup support for path-style folder references
const TOP_LEVEL_FOLDERS = [
{ id: "inbox", displayName: "Inbox" },
{ id: "drafts", displayName: "Drafts" },
{ id: "sentItems", displayName: "Sent Items" },
{ id: "deleteditems", displayName: "Deleted Items" },
{ id: "tramite", displayName: "Tramite" }
];
const CHILD_FOLDERS = {
"inbox": [
{ id: "inbox-child", displayName: "InboxChild" }
],
"tramite": [
{ id: "req-104951-id", displayName: "REQ-104951" }
]
};
const folders = path.includes('childFolders')
? (() => {
const parentId = path.split('/').find((segment, index, parts) => {
return parts[index - 1] === 'mailFolders' && parts[index + 1] === 'childFolders';
});
return CHILD_FOLDERS[parentId] || [];
})()
: TOP_LEVEL_FOLDERS;
const requestedName = queryParams.$filter
?.match(/^displayName eq '((?:''|[^'])*)'$/)?.[1]
?.replace(/''/g, "'");
return {
value: requestedName
? folders.filter(folder => folder.displayName === requestedName)
: folders
};
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@utils/mock-data.js` around lines 123 - 144, Update the mock mail-folder
response logic in the path resolver to honor queryParams.$filter when selecting
top-level folders, returning only the matching folder instead of the entire
collection. Extend CHILD_FOLDERS with the documented tramite hierarchy,
including the REQ-104951 child, so Tramite/REQ-104951 resolution works in test
mode while preserving existing inbox behavior.

@codeant-ai

codeant-ai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

User does not have a PR Review subscription.

Go to Team management and add this email to the PR Review subscription.

@rafaga2469 rafaga2469 closed this Aug 13, 2026
@rafaga2469
rafaga2469 deleted the fix/subfolder-move-emails branch August 13, 2026 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(folder): add parentFolder support to move-emails for subfolder targets move-emails fails to find subfolder targets (e.g. Tramite/REQ-104951)

1 participant