feat(jobs): add Jobs.stop() method [PLT-100574]#337
feat(jobs): add Jobs.stop() method [PLT-100574]#337ninja-shreyash wants to merge 1 commit intomainfrom
Conversation
Add stop method to the Jobs service that stops one or more jobs by their UUID keys. Resolves keys to integer IDs in batches of 50, then calls the StopJobs OData action. Supports SoftStop and Kill strategies. Also adds text responseType handling to api-client for endpoints returning empty 200 responses. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3b444e9 to
7f5050b
Compare
|
|
|
||
| const missingKeys = uniqueKeys.filter((key) => !keyToIdMap.has(key)); | ||
| if (missingKeys.length > 0) { | ||
| throw new Error(`Jobs not found for keys: ${missingKeys.join(', ')}`); |
There was a problem hiding this comment.
Plain Error escapes the typed error hierarchy — callers can't distinguish this from network errors or server failures. Since these are user-supplied keys that don't correspond to any job, ValidationError is the right type (same import already in the file).
| throw new Error(`Jobs not found for keys: ${missingKeys.join(', ')}`); | |
| throw new ValidationError({ message: `Jobs not found for keys: ${missingKeys.join(', ')}` }); |
| const response = await this.get<CollectionResponse<{ Key: string; Id: number }>>( | ||
| JOB_ENDPOINTS.GET_ALL, | ||
| { | ||
| params: { $filter: filter, $select: 'Id,Key' }, |
There was a problem hiding this comment.
Missing $top is a latent bug. Without it the endpoint uses its default page size (typically 20 for Orchestrator OData). A chunk can contain up to 50 keys; if the API pages at 20, the last 30 keys would always be flagged as not found even when they exist.
| params: { $filter: filter, $select: 'Id,Key' }, | |
| params: { $filter: filter, $select: 'Id,Key', $top: chunk.length }, |
|
|
||
| if (!folderId) { | ||
| console.warn('INTEGRATION_TEST_FOLDER_ID not configured, skipping stop test.'); | ||
| return; |
There was a problem hiding this comment.
Per the integration test rules, console.warn + return is reserved for preconditions outside the test's control (e.g. no running jobs available). Missing folderId is a misconfigured environment — the test simply cannot run. That case should throw so CI doesn't silently pass unconfigured tests.
| return; | |
| throw new Error('INTEGRATION_TEST_FOLDER_ID not configured — cannot run stop test.'); |
| * const killResult = await jobs.stop( | ||
| * ['c80c3b30-f010-4eb8-82d4-b67bc615e137', '24ef1040-454d-4184-b994-c641ee32318d'], | ||
| * 123, | ||
| * { strategy: StopStrategy.Kill } |
There was a problem hiding this comment.
StopStrategy is used in the second example but never imported, so the snippet won't compile as written. Add it to the existing import line shown earlier in the example.
| * { strategy: StopStrategy.Kill } | |
| * { strategy: StopStrategy.Kill } |
The first @example import line should read:
import { Jobs, StopStrategy } from '@uipath/uipath-typescript/jobs';


Method Added
jobs.stop()stop(jobKeys: string[], folderId: number, options?: JobStopOptions): Promise<OperationResponse<JobStopData>>Endpoint Called
stop()(resolve)/orchestrator_/odata/JobsOR.Jobsstop()(action)/orchestrator_/odata/Jobs/UiPath.Server.Configuration.OData.StopJobsOR.JobsFolderScopedService— setsX-UIPATH-OrganizationUnitIdheaderSoftStop(graceful) andKill(forceful) strategies via existingStopStrategyenumExample Usage
API Response vs SDK Response
Composition flow
Additional fix
Added
responseType: 'text'handling toapi-client.tsfor endpoints returning empty HTTP 200 bodies (StopJobs returns 200 with no body, not 204).Files
src/utils/constants/endpoints/orchestrator.tssrc/models/orchestrator/jobs.types.tssrc/models/orchestrator/jobs.models.tssrc/services/orchestrator/jobs/jobs.tssrc/core/http/api-client.ts(text responseType support)tests/unit/services/orchestrator/jobs.test.ts(12 tests)tests/integration/shared/orchestrator/jobs.integration.test.ts(5 tests)tests/utils/constants/jobs.tsdocs/oauth-scopes.mdRefs PLT-100574
🤖 Auto-generated using onboarding skills