Skip to content

test: fix flaky legacy-layout agent create NUT (Bot User race) - #358

Draft
nico-pappagianis wants to merge 1 commit into
mainfrom
chore/fix-nut-user-race-condition
Draft

test: fix flaky legacy-layout agent create NUT (Bot User race)#358
nico-pappagianis wants to merge 1 commit into
mainfrom
chore/fix-nut-user-race-condition

Conversation

@nico-pappagianis

Copy link
Copy Markdown
Collaborator

What

The agent create > should retrieve the legacy Bot / GenAiPlanner layout ... NUT (test/nuts/agent.nut.ts) fails intermittently, pod-dependent, with:

Error creating agent : User doesn't have access to agent.
isSuccess: false   // expected false to equal true

Root cause

The customer agentType maps to core's EinsteinServiceAgent, which requires a Bot User holding the Digital Agent license + AgentforceServiceAgentUser permset. When Agent.create is called with no agentSettings.userId, core auto-creates that Bot User in the same transaction as the BotDefinition save; the pre-save validation trigger intermittently cannot see the just-created license/permset assignment and rejects with "User doesn't have access to agent."

The describe's before hook already pre-provisions a Bot User, assigns the permset, and waits for the assignment to commit (waitForPermSetAssignment), storing it in botUserId. The sibling should create an agent from a spec test already passes userId: botUserId; this legacy test never got the same fix.

Fix

Pass userId: botUserId in the legacy test's agentSettings so core reuses the already-committed user instead of racing on a fresh one.

Testing

  • yarn tsc -b passes.
  • The NUT needs a scratch org + default dev hub, not run in this environment. Because the failure is a race, verify with several runs across pods:
    TESTKIT_HUB_USERNAME="<devhub>" yarn mocha "test/nuts/agent.nut.ts" --grep "agent create" --timeout 1800000 --slow 4500

Test-only change; no runtime code touched.

The legacy-layout 'agent create' NUT omitted agentSettings.userId, so core
auto-created the licensed Bot User in the same transaction as the BotDefinition
save. The pre-save validation trigger intermittently could not see the fresh
license/permset assignment, failing with 'User doesn't have access to agent.'

Pass the userId of the Bot User already provisioned (and waited on) in the
describe's before hook, matching the sibling spec-create test, so core reuses an
already-committed user instead of racing on a new one.
@github-actions

Copy link
Copy Markdown

This PR lacks any commits of the 'fix' or 'feat' type, and therefore will not trigger a release. To silence all further warnings, react to this warning comment (or any other) with the 👀 emoji.

NOTE: If your repo uses squash commits, make sure to add the appropriate conventional commit prefix (e.g., 'fix:', 'feat:', 'chore:', etc) in the squash commit message.

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.

1 participant