@onlineapps/conn-orch-orchestrator 1.0.24 → 1.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/WorkflowOrchestrator.js +74 -2
package/package.json
CHANGED
|
@@ -280,7 +280,34 @@ class WorkflowOrchestrator {
|
|
|
280
280
|
* @returns {Promise<Object>} API call result
|
|
281
281
|
*/
|
|
282
282
|
async _executeTaskStep(step, context) {
|
|
283
|
-
//
|
|
283
|
+
// FAIL-FAST: Verify context exists
|
|
284
|
+
if (!context) {
|
|
285
|
+
const error = new Error(`Context is missing for step ${step.step_id}`);
|
|
286
|
+
this.logger.error('[WorkflowOrchestrator] [FAIL-FAST] Missing context', { step_id: step.step_id });
|
|
287
|
+
throw error;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// Debug: log context keys and api_input
|
|
291
|
+
console.log(`[WorkflowOrchestrator] [RESOLVE] Step ${step.step_id} - context keys:`, Object.keys(context || {}));
|
|
292
|
+
|
|
293
|
+
// FAIL-FAST: Log api_input state (but don't fail if missing - it might not be needed)
|
|
294
|
+
if (context.api_input === undefined) {
|
|
295
|
+
console.warn(`[WorkflowOrchestrator] [WARNING] Step ${step.step_id} - context.api_input is undefined - template references like {{api_input.field}} will fail`);
|
|
296
|
+
} else if (context.api_input === null) {
|
|
297
|
+
console.warn(`[WorkflowOrchestrator] [WARNING] Step ${step.step_id} - context.api_input is null - template references like {{api_input.field}} will fail`);
|
|
298
|
+
} else if (typeof context.api_input !== 'object' || Array.isArray(context.api_input)) {
|
|
299
|
+
const error = new Error(`Invalid api_input type for step ${step.step_id}: expected object, got ${typeof context.api_input}`);
|
|
300
|
+
console.error(`[WorkflowOrchestrator] [FAIL-FAST] Invalid api_input type:`, {
|
|
301
|
+
step_id: step.step_id,
|
|
302
|
+
api_input_type: typeof context.api_input,
|
|
303
|
+
api_input_value: context.api_input,
|
|
304
|
+
is_array: Array.isArray(context.api_input)
|
|
305
|
+
});
|
|
306
|
+
throw error;
|
|
307
|
+
} else {
|
|
308
|
+
console.log(`[WorkflowOrchestrator] [RESOLVE] Step ${step.step_id} - context.api_input:`, JSON.stringify(context.api_input));
|
|
309
|
+
}
|
|
310
|
+
|
|
284
311
|
console.log(`[WorkflowOrchestrator] [RESOLVE] Step ${step.step_id} - context.steps keys:`,
|
|
285
312
|
context.steps ? Object.keys(context.steps) : 'NO STEPS');
|
|
286
313
|
|
|
@@ -289,6 +316,18 @@ class WorkflowOrchestrator {
|
|
|
289
316
|
const resolvedInput = this._resolveInputReferences(step.input, context);
|
|
290
317
|
console.log(`[WorkflowOrchestrator] [RESOLVE] Step ${step.step_id} input AFTER:`, JSON.stringify(resolvedInput));
|
|
291
318
|
|
|
319
|
+
// FAIL-FAST: Check if template references were resolved
|
|
320
|
+
const inputStr = JSON.stringify(resolvedInput);
|
|
321
|
+
if (inputStr.includes('{{api_input.') || inputStr.includes('${api_input.')) {
|
|
322
|
+
console.error(`[WorkflowOrchestrator] [FAIL-FAST] Unresolved api_input template in step ${step.step_id}:`, {
|
|
323
|
+
step_id: step.step_id,
|
|
324
|
+
resolved_input: resolvedInput,
|
|
325
|
+
context_api_input: context.api_input,
|
|
326
|
+
context_keys: Object.keys(context)
|
|
327
|
+
});
|
|
328
|
+
throw new Error(`Template reference to api_input not resolved in step ${step.step_id} - check that api_input is in context`);
|
|
329
|
+
}
|
|
330
|
+
|
|
292
331
|
// Use API mapper to call the service with resolved input
|
|
293
332
|
const result = await this.apiMapper.callOperation(
|
|
294
333
|
step.operation,
|
|
@@ -376,6 +415,12 @@ class WorkflowOrchestrator {
|
|
|
376
415
|
* @returns {*} Resolved value or undefined
|
|
377
416
|
*/
|
|
378
417
|
_getValueFromPath(path, context) {
|
|
418
|
+
// FAIL-FAST: Verify context exists
|
|
419
|
+
if (!context) {
|
|
420
|
+
console.error('[WorkflowOrchestrator] [FAIL-FAST] _getValueFromPath called with null/undefined context', { path });
|
|
421
|
+
throw new Error(`Cannot resolve path '${path}': context is null or undefined`);
|
|
422
|
+
}
|
|
423
|
+
|
|
379
424
|
// V2: steps is an object keyed by step_id, not an array
|
|
380
425
|
// Support both formats for backward compatibility during migration:
|
|
381
426
|
// - steps.step_id.output.field (V2, preferred)
|
|
@@ -400,9 +445,36 @@ class WorkflowOrchestrator {
|
|
|
400
445
|
|
|
401
446
|
const parts = normalized.split('.');
|
|
402
447
|
|
|
448
|
+
// FAIL-FAST: Log api_input access attempts
|
|
449
|
+
if (normalized.startsWith('api_input.')) {
|
|
450
|
+
console.log(`[WorkflowOrchestrator] [GET_VALUE] Resolving api_input path: ${path} -> ${normalized}`);
|
|
451
|
+
console.log(`[WorkflowOrchestrator] [GET_VALUE] context.api_input exists:`, context.api_input !== undefined);
|
|
452
|
+
console.log(`[WorkflowOrchestrator] [GET_VALUE] context.api_input type:`, typeof context.api_input);
|
|
453
|
+
if (context.api_input) {
|
|
454
|
+
console.log(`[WorkflowOrchestrator] [GET_VALUE] context.api_input keys:`, Object.keys(context.api_input));
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
403
458
|
let current = context;
|
|
404
459
|
for (const part of parts) {
|
|
405
|
-
if (current === undefined || current === null)
|
|
460
|
+
if (current === undefined || current === null) {
|
|
461
|
+
// FAIL-FAST: Log failed resolution for api_input
|
|
462
|
+
if (normalized.startsWith('api_input.')) {
|
|
463
|
+
console.error(`[WorkflowOrchestrator] [FAIL-FAST] Failed to resolve api_input path: ${path}`, {
|
|
464
|
+
path,
|
|
465
|
+
normalized,
|
|
466
|
+
parts,
|
|
467
|
+
failed_at_part: part,
|
|
468
|
+
current_type: typeof current,
|
|
469
|
+
context_keys: Object.keys(context),
|
|
470
|
+
context_has_api_input: 'api_input' in context,
|
|
471
|
+
api_input_type: typeof context.api_input,
|
|
472
|
+
api_input_keys: context.api_input ? Object.keys(context.api_input) : null
|
|
473
|
+
});
|
|
474
|
+
throw new Error(`Failed to resolve api_input path '${path}': '${part}' is undefined in context`);
|
|
475
|
+
}
|
|
476
|
+
return undefined;
|
|
477
|
+
}
|
|
406
478
|
|
|
407
479
|
// Special handling for steps: if accessing by numeric index and steps is object,
|
|
408
480
|
// try to find step by index in cookbook (fallback for legacy)
|