Skip to content

Fix data-driven AI tests failing when TestPermissions is not Disabled#8438

Merged
Groenbech96 merged 3 commits into
mainfrom
bugs/636024-testinput-permissions
Jun 4, 2026
Merged

Fix data-driven AI tests failing when TestPermissions is not Disabled#8438
Groenbech96 merged 3 commits into
mainfrom
bugs/636024-testinput-permissions

Conversation

@Groenbech96
Copy link
Copy Markdown
Contributor

@Groenbech96 Groenbech96 commented Jun 3, 2026

Summary

Data-driven tests run by the AI Test Suite Runner fail when the test method declares a TestPermissions value other than Disabled.

The data-driven test framework reads the Test Input table from a subscriber to OnBeforeTestMethodRun (codeunit 130460 Test Input). The platform raises that event inside the test method's TestPermissions scope, so the effective permissions are overridden and the IndirectRead on table Test Input fails:

Sorry, the current permissions prevented the action.
(TableData 130452 Test Input IndirectRead: Test Runner)
The user permissions have been overridden by the TestPermissions property.

Because the permission execution context is overridden by TestPermissions, the codeunit's own Permissions property is not honored in that window, so the read cannot succeed there.

Work Item(s)

Fixes AB#636024

Fix

Load the test input earlier, while still running under full permissions. The AI Test Toolkit input handler already has a pre-permission hook (OnBeforeRunTestMethodLine, raised before the test runner codeunit is invoked). It now pre-loads the input into the single-instance Test Input globals via a new PreloadTestInput method, so the later read inside the restricted TestPermissions scope becomes a no-op (the existing early-exit guard returns before the Get).

  • Test Input (130460): extracted the load logic into a shared LoadTestInput helper and exposed PreloadTestInput(GroupCode, InputCode).
  • AIT Test Run Input Handler (149045): calls PreloadTestInput from its existing OnBeforeRunTestMethodLine subscriber.

🤖 Generated with Claude Code

The data-driven test framework reads the "Test Input" table from a subscriber to
OnBeforeTestMethodRun (codeunit 130460 "Test Input"). The platform raises that
event inside the test method's TestPermissions scope. When a test declares a
TestPermissions value other than Disabled, the platform overrides the effective
permissions and the IndirectRead on table "Test Input" fails:

  Sorry, the current permissions prevented the action.
  (TableData 130452 Test Input IndirectRead: Test Runner)
  The user permissions have been overridden by the TestPermissions property.

Because the permission execution context is overridden by TestPermissions, the
codeunit's own Permissions property is not honored during that window, so the read
cannot succeed there.

Load the test input earlier, while still running under full permissions: the AI
Test Toolkit input handler already has a pre-permission hook
(OnBeforeRunTestMethodLine, raised before the test runner is invoked). It now
pre-loads the input into the single-instance "Test Input" globals via the new
PreloadTestInput method, so the later read inside the restricted scope is a no-op.

Fixes AB#636024

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Groenbech96 Groenbech96 requested a review from a team as a code owner June 3, 2026 11:52
@github-actions github-actions Bot added this to the Version 29.0 milestone Jun 3, 2026
nikolakukrika
nikolakukrika previously approved these changes Jun 4, 2026
darjoo
darjoo previously approved these changes Jun 4, 2026
@Groenbech96
Copy link
Copy Markdown
Contributor Author

@copilot Can you look at darjoos comment to follow standard?

Copilot AI dismissed stale reviews from darjoo and nikolakukrika via e5ca086 June 4, 2026 07:21
Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 4, 2026

@copilot Can you look at darjoos comment to follow standard?

Fixed in e64f55d by converting the PreloadTestInput comment block to our standard XML documentation format and preserving the original remark wording.

@Groenbech96 Groenbech96 enabled auto-merge (squash) June 4, 2026 07:25
@Groenbech96 Groenbech96 merged commit 325c9a9 into main Jun 4, 2026
87 of 89 checks passed
@Groenbech96 Groenbech96 deleted the bugs/636024-testinput-permissions branch June 4, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants