@onlineapps/conn-orch-orchestrator 1.0.25 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlineapps/conn-orch-orchestrator",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "description": "Workflow orchestration connector for OA Drive - handles message routing and workflow execution",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -280,9 +280,34 @@ class WorkflowOrchestrator {
280
280
  * @returns {Promise<Object>} API call result
281
281
  */
282
282
  async _executeTaskStep(step, context) {
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
+
283
290
  // Debug: log context keys and api_input
284
291
  console.log(`[WorkflowOrchestrator] [RESOLVE] Step ${step.step_id} - context keys:`, Object.keys(context || {}));
285
- console.log(`[WorkflowOrchestrator] [RESOLVE] Step ${step.step_id} - context.api_input:`, JSON.stringify(context?.api_input || {}));
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
+
286
311
  console.log(`[WorkflowOrchestrator] [RESOLVE] Step ${step.step_id} - context.steps keys:`,
287
312
  context.steps ? Object.keys(context.steps) : 'NO STEPS');
288
313
 
@@ -291,6 +316,18 @@ class WorkflowOrchestrator {
291
316
  const resolvedInput = this._resolveInputReferences(step.input, context);
292
317
  console.log(`[WorkflowOrchestrator] [RESOLVE] Step ${step.step_id} input AFTER:`, JSON.stringify(resolvedInput));
293
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
+
294
331
  // Use API mapper to call the service with resolved input
295
332
  const result = await this.apiMapper.callOperation(
296
333
  step.operation,
@@ -378,6 +415,12 @@ class WorkflowOrchestrator {
378
415
  * @returns {*} Resolved value or undefined
379
416
  */
380
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
+
381
424
  // V2: steps is an object keyed by step_id, not an array
382
425
  // Support both formats for backward compatibility during migration:
383
426
  // - steps.step_id.output.field (V2, preferred)
@@ -402,9 +445,36 @@ class WorkflowOrchestrator {
402
445
 
403
446
  const parts = normalized.split('.');
404
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
+
405
458
  let current = context;
406
459
  for (const part of parts) {
407
- if (current === undefined || current === null) return undefined;
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
+ }
408
478
 
409
479
  // Special handling for steps: if accessing by numeric index and steps is object,
410
480
  // try to find step by index in cookbook (fallback for legacy)