Skip to content

[29.x] Prevent Sales Order Agent from skipping emails moved into monitored folders - #11097

Open
tomasevicst wants to merge 1 commit into
releases/29.xfrom
bugs/649175_SOA_Folder_Monitoring_Skip_Emails_29.x
Open

[29.x] Prevent Sales Order Agent from skipping emails moved into monitored folders#11097
tomasevicst wants to merge 1 commit into
releases/29.xfrom
bugs/649175_SOA_Folder_Monitoring_Skip_Emails_29.x

Conversation

@tomasevicst

@tomasevicst tomasevicst commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

What & why

Stop advancing Earliest Sync At after email polling. Moved emails retain their original received timestamp, so advancing this value could permanently exclude them from later retrieval.

The configured Start Date remains the retrieval lower bound, while Graph excludes emails already categorized as processed. Added regression tests for empty and under-full polling.

Linked work

Fixes AB#649175

How I validated this

  • I read the full diff and it contains only changes I intended.
  • I built the affected app(s) locally with no new analyzer warnings.
  • I ran the change in Business Central and confirmed it behaves as expected.
  • I added or updated tests for the new behavior, or explained below why none are needed.

What I tested and the outcome (required — be specific: scenarios, commands, screenshots for UI changes)

Risk & compatibility

Low risk. No schema, API, setup, or connector changes. Existing Start Date behavior during setup, reactivation, and mailbox changes remains unchanged. Previously processed emails continue to be excluded server-side by their Outlook category.

@tomasevicst
tomasevicst requested a review from a team September 5, 2026 20:46
@tomasevicst
tomasevicst requested a review from a team as a code owner September 5, 2026 20:46
@github-actions github-actions Bot added AL: Apps (W1) Add-on apps for W1 Team: SCM GitHub request for SCM area labels Sep 5, 2026
@github-actions github-actions Bot added this to the Version 29.1 milestone Sep 5, 2026
@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Good Sense Reviewer - Round 1

Recommendation: Accept with Suggestions

What this PR does

This removes the runtime update that moved Earliest Sync At forward after each email retrieval. That keeps the configured start date as the lower bound for folder polling, so a message that is received earlier but moved into the monitored folder later can still be returned.

The change fits the failing path: the Outlook query still scopes to the configured folder and excludes messages already categorized as processed, while existing task-message checks protect against duplicate task messages. No event surface or BaseApp dependency changed, and there is no Sales/Purchase/Service parallel to align for this Sales Order Agent-specific polling code.

Problem-solution fit

Fit: Strong

The bug is a clear watermark race: an eligible message can enter the monitored folder after the poll time, but keep an older received time. Removing the polling-time watermark update directly prevents that permanent exclusion and keeps duplicate protection in the existing category and external-message checks.

Suggestions

S1 (🟠 Moderate): Add regression coverage for moved emails
The changed files do not include a regression test for the folder-move race. Please add a test where an email is received before a poll, moves into the monitored folder after the poll, and repeated retrieval does not create duplicate agent tasks.

Risk assessment and necessity

Risk: The regression surface is limited to Sales Order Agent email polling. The main tradeoff is that Graph queries keep using the configured start date, but the processed category, $top batching, and existing external-message checks limit duplicate work. App builds are green; several unit-test buckets were still running when checked.

Necessity: The change is required because otherwise polling can report success while eligible emails are never discovered. The scope is small and removes the behavior that caused the skip without changing schema, public APIs, setup flow, or connector contracts.


[AI-PR-REVIEW] version=1 promptVersion=4 system=github pr=11097 round=1 by=alexei-dobriansky at=2026-09-06T00:12:57Z lastSha=372f1108ad3ad6755f1c7b64d80e0be6ce355194 reviewKey=170c322c0abc31c723b6f73be74bebd2e7a26e45280f847e3fa4b8b5ff1282ad suggestions=S1@1f0e1b8e

@tomasevicst
tomasevicst enabled auto-merge (squash) September 6, 2026 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1 Team: SCM GitHub request for SCM area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants