coleam00/Archon · warning

Warning: --data is not valid JSON — event will be emitted…

Error message

Warning: --data is not valid JSON — event will be emitted without data payload: ${rawData}

What it means

The archon CLI 'workflow event emit' command (packages/cli/src/cli.ts:1054) parses the --data flag as JSON. When parsing fails it does not abort: it prints this warning and emits the event with no data payload (eventData stays undefined), so downstream nodes waiting on the event receive an empty data object.

Solutions

  1. Quote the whole --data value and use valid JSON: --data '{"key":"value"}'
  2. Build the payload with a JSON serializer (jq -n, JSON.stringify) instead of hand-writing it
  3. Check the warning output: the raw value is echoed, so inspect what the shell actually passed
  4. If the event legitimately needs no payload, omit --data instead of passing malformed JSON

Example fix

// before
archon workflow event emit $RUN done --data status=ok
# after
archon workflow event emit $RUN done --data '{"status":"ok"}'
Defensive patterns

Strategy: validation

Validate before calling

// Validate --data before invoking the CLI:
const raw = process.argv[process.argv.indexOf('--data') + 1];
if (raw !== undefined) JSON.parse(raw); // throws early with a clear message
// shell: jq -n --arg s ok '{status: $s}' to build the payload

Type guard

function isValidJsonObject(raw) {
  try { const v = JSON.parse(raw); return typeof v === 'object' && v !== null && !Array.isArray(v); }
  catch { return false; }
}

Try / catch

// The CLI itself warns and continues (fallback: no data payload). To make it fatal:
const raw = getValue('--data');
if (raw !== undefined && !isValidJsonObject(raw)) {
  throw new Error(`--data must be valid JSON, got: ${raw}`);
}
await workflowEventEmitCommand(runId, eventType, eventData);

Prevention

When it happens

Trigger: Running a CLI command like `archon workflow event emit <runId> <eventType> --data '...'` where the --data value is not valid JSON — unquoted shell values, keys without quotes, single quotes inside the value, or shell word-splitting truncating the payload.

Common situations: Passing --data foo=bar instead of JSON; shell stripping inner quotes so JSON.parse fails; hand-built JSON with smart quotes; forgetting to wrap the value in single quotes so spaces split arguments.

Related errors


AI-assisted analysis of coleam00/Archon@0773b97458 (2026-09-01). Data as JSON: /api/errors/0002313aacec8027. Report an issue: GitHub.

Appendix: source

Thrown at packages/cli/src/cli.ts:1054

                jsonFlag,
                'Usage: archon workflow event emit --run-id <run-id> --type <event-type>\n' +
                  'Error: --type is required'
              );
            }
            if (!isValidEventType(eventType)) {
              const { WORKFLOW_EVENT_TYPES } = await import('@archon/workflows/store');
              return await fail(
                jsonFlag,
                `Error: unknown event type: ${eventType}\nValid types: ${WORKFLOW_EVENT_TYPES.join(', ')}`
              );
            }
            let eventData: Record<string, unknown> | undefined;
            const rawData = values.data as string | undefined;
            if (rawData) {
              try {
                eventData = JSON.parse(rawData) as Record<string, unknown>;
              } catch {
                console.warn(
                  `Warning: --data is not valid JSON — event will be emitted without data payload: ${rawData}`
                );
              }
            }
            await workflowEventEmitCommand(runId, eventType, eventData, effectiveCwd);
            break;
          }

          case 'install': {
            const installSlug = positionals[2];
            if (!installSlug) {
              return await fail(jsonFlag, 'Usage: archon workflow install <slug> [--force]');
            }
            const forceFlag = values.force as boolean | undefined;
            await workflowInstallCommand(installSlug, effectiveCwd, forceFlag);
            break;
          }

View on GitHub (pinned to 0773b97458)