File tree Expand file tree Collapse file tree 4 files changed +31
-3
lines changed
packages/core/src/v3/apiClient
references/v3-catalog/src Expand file tree Collapse file tree 4 files changed +31
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @trigger.dev/core " : patch
3
+ ---
4
+
5
+ Support triggering tasks with non-URL friendly characters in the ID
Original file line number Diff line number Diff line change @@ -111,9 +111,11 @@ export class ApiClient {
111
111
}
112
112
113
113
triggerTask ( taskId : string , body : TriggerTaskRequestBody , options ?: TriggerOptions ) {
114
+ const encodedTaskId = encodeURIComponent ( taskId ) ;
115
+
114
116
return zodfetch (
115
117
TriggerTaskResponse ,
116
- `${ this . baseUrl } /api/v1/tasks/${ taskId } /trigger` ,
118
+ `${ this . baseUrl } /api/v1/tasks/${ encodedTaskId } /trigger` ,
117
119
{
118
120
method : "POST" ,
119
121
headers : this . #getHeaders( options ?. spanParentAsLink ?? false ) ,
@@ -124,9 +126,11 @@ export class ApiClient {
124
126
}
125
127
126
128
batchTriggerTask ( taskId : string , body : BatchTriggerTaskRequestBody , options ?: TriggerOptions ) {
129
+ const encodedTaskId = encodeURIComponent ( taskId ) ;
130
+
127
131
return zodfetch (
128
132
BatchTriggerTaskResponse ,
129
- `${ this . baseUrl } /api/v1/tasks/${ taskId } /batch` ,
133
+ `${ this . baseUrl } /api/v1/tasks/${ encodedTaskId } /batch` ,
130
134
{
131
135
method : "POST" ,
132
136
headers : this . #getHeaders( options ?. spanParentAsLink ?? false ) ,
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { createReadStream } from "node:fs";
4
4
import { firstScheduledTask } from "./trigger/scheduled" ;
5
5
import { simpleChildTask } from "./trigger/subtasks" ;
6
6
import { taskThatErrors } from "./trigger/retries" ;
7
+ import { unfriendlyIdTask } from "./trigger/other" ;
7
8
8
9
dotenv . config ( ) ;
9
10
@@ -261,8 +262,19 @@ async function doScheduleLists() {
261
262
}
262
263
}
263
264
265
+ async function doTriggerUnfriendlyTaskId ( ) {
266
+ const run = await unfriendlyIdTask . trigger ( ) ;
267
+
268
+ console . log ( "unfriendly id task run" , run ) ;
269
+
270
+ const completedRun = await waitForRunToComplete ( run . id ) ;
271
+
272
+ console . log ( "completed run" , completedRun ) ;
273
+ }
274
+
264
275
// doRuns().catch(console.error);
265
- doListRuns ( ) . catch ( console . error ) ;
276
+ // doListRuns().catch(console.error);
266
277
// doScheduleLists().catch(console.error);
267
278
// doSchedules().catch(console.error);
268
279
// doEnvVars().catch(console.error);
280
+ doTriggerUnfriendlyTaskId ( ) . catch ( console . error ) ;
Original file line number Diff line number Diff line change @@ -75,3 +75,10 @@ export const consecutiveDependencyAndWait = task({
75
75
logger . log ( "logs after" ) ;
76
76
} ,
77
77
} ) ;
78
+
79
+ export const unfriendlyIdTask = task ( {
80
+ id : "hello/world:task-1" ,
81
+ run : async ( ) => {
82
+ console . log ( "Hello world" ) ;
83
+ } ,
84
+ } ) ;
You can’t perform that action at this time.
0 commit comments