Skip to content

Fix #817: find the Automated Process user by username in LogFlowExecutionErrorEventHandler_Tests - #1040

Open
kacrouse wants to merge 1 commit into
jongpie:mainfrom
kacrouse:bugfix/817-autoproc-user-lookup
Open

kacrouse wants to merge 1 commit into
jongpie:mainfrom
kacrouse:bugfix/817-autoproc-user-lookup

Conversation

@kacrouse

Copy link
Copy Markdown
Contributor

Summary

Fixes #817. it_logs_when_enabled looks up the Automated Process user by Alias = 'autoproc'. In some orgs, Salesforce renamed this user to "Platform Integration User" with alias platint. The user is read-only, so admins cannot change the alias back. The username is still autoproc@<org ID>:

-System.runAs(new Schema.User(Id = [SELECT Id FROM User WHERE Alias = 'autoproc'].Id)) {
+System.runAs(new Schema.User(Id = [SELECT Id FROM User WHERE Username = :'autoproc@' + System.UserInfo.getOrganizationId()].Id)) {

UserType = 'AutomatedProcess' cannot replace the alias filter, because it returns 4 users in our org: autoproc@, automatedcase@, automatedclean@ and slackbot@.

Evidence

  • Before: System.QueryException: List has no rows for assignment to SObject in our production org and every sandbox. The Automated Process user there is autoproc@00d8y000001ziriuac, with alias platint.
  • After:
    • In our sandbox (core 4.19.5, Async Failure Additions 1.0.3), where the user has alias platint, LogFlowExecutionErrorEventHandler_Tests passes 2/2.
    • In a new scratch org (config/scratch-orgs/base-scratch-def.json, all of ./nebula-logger/ deployed), all local tests pass: 1461/1461. There the user still has alias autoproc, so the username lookup also works in orgs where the user was not renamed.
  • Prettier and PMD (the pre-commit hook checks): no changes, 0 violations.

Merge Danger

Door: two-way

Blast Radius: none

Test-only change in the Async Failure Additions plugin.

🤖 Generated with Claude Code

…ventHandler_Tests

Fixes jongpie#817. Salesforce renamed the Automated Process user to "Platform
Integration User" with alias "platint" in some orgs, and the user cannot
be edited. The username is still autoproc@<org ID>, so the test now
queries by username.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kacrouse
kacrouse requested a review from jongpie as a code owner November 20, 2026 18:39

This branch has not been deployed

No deployments
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.

Failing Unit Test: LogFlowExecutionErrorEventHandler_Tests. it_logs_when_enabled

1 participant