Stirling-Tools/Stirling-PDF · warning · Error

Invalid folder scanning config: pipeline[${index}].operation

Error message

Invalid folder scanning config: pipeline[${index}].operation must be a non-empty string

What it means

Thrown when a pipeline step's operation field is missing, not a string, or empty. operation must be a non-empty string (an endpoint path or frontend tool id).

Source

Thrown at frontend/editor/src/core/utils/automationConverter.ts:252

  const pipeline = obj.pipeline;
  if (!Array.isArray(pipeline)) {
    throw new Error("Invalid folder scanning config: missing 'pipeline' array");
  }

  const endpointMap = buildEndpointToToolIdMap(toolRegistry);
  const unresolved: string[] = [];

  const operations: AutomationOperation[] = pipeline.map(
    (step: unknown, index: number) => {
      if (!step || typeof step !== "object") {
        throw new Error(
          `Invalid folder scanning config: pipeline[${index}] is not an object`,
        );
      }
      const stepObj = step as Record<string, unknown>;
      const rawOperation = stepObj.operation;
      if (typeof rawOperation !== "string" || rawOperation.length === 0) {
        throw new Error(
          `Invalid folder scanning config: pipeline[${index}].operation must be a non-empty string`,
        );
      }
      const rawParameters = (stepObj.parameters as Record<string, any>) || {};
      // Strip the export-time marker so the imported automation runs cleanly.
      const { fileInput: _fileInput, ...parameters } = rawParameters;

      // 1) Direct frontend-tool-id match (handles the converter's fallback when
      //    no endpoint could be resolved at export time).
      if (isToolIdInRegistry(rawOperation, toolRegistry)) {
        return { operation: rawOperation, parameters };
      }

      // 2) Static endpoint string match.
      const staticMatch = endpointMap.get(rawOperation);
      if (staticMatch) {
        return { operation: staticMatch, parameters };
      }

View on GitHub (pinned to 9ef20dcab8)

Solutions

  1. Ensure each step has a non-empty string operation.
  2. Re-export the config.
  3. Validate each step against a schema before mapping.

Example fix

// before
if (typeof rawOperation !== 'string' || rawOperation.length === 0) throw new Error('operation must be a non-empty string');

// after
const schema = { operation: 'string' };
const ok = pipeline.every((s) => typeof s?.operation === 'string' && s.operation.length > 0);
if (!ok) throw new Error('Each pipeline step needs a non-empty operation string.');
Defensive patterns

Strategy: validation

Validate before calling

const bad = pipeline.findIndex((s) => typeof (s as any)?.operation !== 'string' || !(s as any).operation);
if (bad !== -1) throw new Error(`pipeline[${bad}].operation must be a non-empty string`);

Type guard

function stepHasOperation(s: unknown): s is { operation: string } {
  return !!s && typeof (s as any).operation === 'string' && (s as any).operation.length > 0;
}

Prevention

When it happens

Trigger: step.operation is undefined, null, a number, or an empty string.

Common situations: A typo (e.g. 'Operation'); a step with only parameters; an export from an incompatible tool version that omitted the operation field.

Related errors


AI-assisted analysis of Stirling-Tools/Stirling-PDF@9ef20dcab8 (2026-08-13). Data as JSON: /api/errors/6045f1e4cfed17a7. Report an issue: GitHub.