Skip to content

Prevent Sales Order Agent from skipping emails moved into monitored folders - #11063

Merged
tomasevicst merged 1 commit into
mainfrom
bugs/648911_SOA_Folder_Monitoring_Skip_Emails
Sep 6, 2026
Merged

tomasevicst merged 1 commit into
mainfrom
bugs/648911_SOA_Folder_Monitoring_Skip_Emails

Conversation

@tomasevicst

@tomasevicst tomasevicst commented Sep 4, 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#648911

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 4, 2026 13:41
@tomasevicst
tomasevicst requested a review from a team as a code owner September 4, 2026 13:41
@github-actions github-actions Bot added AL: Apps (W1) Add-on apps for W1 Team: SCM GitHub request for SCM area labels Sep 4, 2026
@github-actions github-actions Bot added this to the Version 30.0 milestone Sep 4, 2026
@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Good Sense Reviewer - Round 1

Recommendation: Accept with Suggestions

What this PR does

This change stops advancing the Sales Order Agent email retrieval lower bound after each folder poll. That lets a message still be found if it was received earlier but moved into the monitored folder after a previous empty poll. Processed messages are still excluded by the existing Outlook category filter, so the change relies on that category as the duplicate guard.

Problem-solution fit

Fit: Strong

The reported problem is a race between folder moves and a received-time polling watermark. Removing the runtime watermark update directly addresses that race, and the surrounding retrieval still filters by folder and excludes messages already marked as processed.

Suggestions

S1 (🟠 Moderate): Add folder polling regression coverage
The changed path removes the only runtime update of the retrieval lower bound, but this diff does not include a test for that behavior. Please add a test for an empty or under-limit folder poll, or explain why the connector mock cannot cover it.

Risk assessment and necessity

Risk: The regression surface is folder-based email polling in Sales Order Agent. The main risk is repeated scanning from the configured lower bound, but the folder filter, max-email limit, and processed category still bound normal processing and duplicate handling.

Necessity: The change is needed because moved messages keep their original received time. Without this change, a successful empty poll can permanently exclude an eligible message from later retrieval.


[AI-PR-REVIEW] version=1 promptVersion=4 system=github pr=11063 round=1 by=alexei-dobriansky at=2026-09-04T18:15:21.3645173Z lastSha=b4243ea664021c78f129280cf662a2328b7fc19c reviewKey=a2d7df95cdbc83488abc15b99b58305851d0451ad3f6613c32c9a7a9d9e997d2 suggestions=S1@1f0e1b8e

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.

The change correctly preserves the configured Start Date as the retrieval lower bound, preventing emails moved into a monitored folder after receipt from being permanently excluded. Processed messages remain excluded server-side by category, and the change is narrowly scoped.

@tomasevicst
tomasevicst added this pull request to the merge queue Sep 6, 2026
Merged via the queue into main with commit 9e586f9 Sep 6, 2026
167 checks passed
@tomasevicst
tomasevicst deleted the bugs/648911_SOA_Folder_Monitoring_Skip_Emails branch September 6, 2026 12:44
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.

4 participants