Skip to content

fix(dashboard): use 'name' instead of 'title' in session.create() to fix PrismaClientValidationError when df:name capability is set#2055

Open
ashish-solankar wants to merge 1 commit into
AppiumTestDistribution:mainfrom
ashish-solankar:fix/session-name-prisma-validation-error
Open

fix(dashboard): use 'name' instead of 'title' in session.create() to fix PrismaClientValidationError when df:name capability is set#2055
ashish-solankar wants to merge 1 commit into
AppiumTestDistribution:mainfrom
ashish-solankar:fix/session-name-prisma-validation-error

Conversation

@ashish-solankar

Copy link
Copy Markdown

Problem

Fixes #2054

When the df:name capability is set (e.g. 'df:name': 'Login Test'), session creation crashes with:

PrismaClientValidationError:
Invalid `prisma.session.create()` invocation:

Unknown argument `buildId`. Did you mean `build`? Available options are marked with ?.

The session is never created. Removing df:name is the only workaround.

Root Cause

In src/dashboard/event-manager.ts, the onSessionStarted method builds the createOptions object using the key title to store the session name from the df:name capability:

const createOptions: Record<string, any> = {
  id: session.getId(),
  buildId: (await getOrCreateNewBuild(capabilities)).id,
  title: capabilities[DEVICE_FARM_CAPABILITIES.SESSION_NAME] || undefined, // ❌ wrong key
  ...
};

The Prisma Session model in prisma/schema.prisma has no title field — the correct field is name:

model Session {
  name String? @map("name")  // ✅ correct field
}

When df:name is not set, title is undefined and Prisma silently ignores the unknown key — so sessions work fine. When df:name has a value, Prisma's strict input validation fires, sees the unknown title field, and rejects the entire createOptions object — including the valid buildId field — which explains the misleading error message pointing at buildId.

Fix

Single one-line change in src/dashboard/event-manager.ts — rename titlename in the createOptions object:

// Before ❌
title: capabilities[DEVICE_FARM_CAPABILITIES.SESSION_NAME] || undefined,

// After ✅
name: capabilities[DEVICE_FARM_CAPABILITIES.SESSION_NAME] || undefined,

Steps to Reproduce

  1. Start Appium with the device-farm plugin (enableDashboard: true)
  2. Pass 'df:name': 'Login Test' (along with df:build) in your test capabilities
  3. Session creation fails with PrismaClientValidationError: Unknown argument 'buildId'

Testing

  • ✅ Session creation succeeds when df:name is set
  • ✅ Session name appears correctly on the dashboard
  • ✅ Sessions without df:name continue to work unchanged
  • df:build, df:accesskey, df:token all continue to work as before

…fix PrismaClientValidationError when df:name capability is set
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.

[Bug] PrismaClientValidationError: Unknown argument 'buildId' on session.create() when df:name capability is set (v11.3.2)

1 participant