different-ai/openwork · warning

${label} syntax: enter valid JSON.

Error message

${label} syntax: enter valid JSON.

What it means

parseJson in workflow-detail-panel.tsx parses user-entered form fields (input, inputSchema, outputSchema) before building a WorkflowDraft. Empty optional fields become undefined; any JSON.parse failure throws '${label} syntax: enter valid JSON.' so the save is aborted with a per-field message.

Source

Thrown at ee/apps/den-web/app/(den)/dashboard/_components/workflow-detail-panel.tsx:34

  useUpdateWorkflowAutomation,
  useWorkflowDetail,
  useWorkflowSnapshots,
} from "./workflow-data";

type Fields = { name: string; description: string; code: string; input: string; inputSchema: string; outputSchema: string };
const AGE_OPTIONS = [{ label: "1 hour", value: 3_600_000 }, { label: "1 day", value: 86_400_000 }, { label: "1 week", value: 604_800_000 }];

function pretty(value: unknown) {
  return value === null || value === undefined ? "" : JSON.stringify(value, null, 2);
}

function initialFields(detail: WorkflowDetail): Fields {
  return { name: detail.title, description: detail.description ?? "", code: detail.currentVersion.code ?? "", input: pretty(detail.currentVersion.exampleInput ?? {}), inputSchema: pretty(detail.currentVersion.inputSchema), outputSchema: pretty(detail.currentVersion.outputSchema) };
}

function parseJson(label: string, value: string, optional = false) {
  if (!value.trim() && optional) return undefined;
  try { return JSON.parse(value.trim() || "null"); } catch { throw new Error(`${label} syntax: enter valid JSON.`); }
}

function toDraft(detail: WorkflowDetail, fields: Fields): WorkflowDraft {
  return {
    name: fields.name.trim(),
    description: fields.description.trim() || undefined,
    code: fields.code,
    exampleInput: parseJson("Example input", fields.input),
    inputSchema: parseJson("Input schema", fields.inputSchema, true),
    outputSchema: parseJson("Output schema", fields.outputSchema, true),
    requiredCapabilities: detail.currentVersion.requiredCapabilities,
  };
}

function message(error: unknown) {
  return error instanceof Error ? error.message : "The Workflow action failed.";
}

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Fix the JSON in the flagged field (validate it in a linter/JSON parser first).
  2. Remove trailing commas, smart quotes, and unquoted keys.
  3. If the field is optional, either leave it fully empty or supply valid JSON.
  4. Re-check required (non-optional) fields are non-empty and parse to the expected object/array.
  5. Paste via a plain-text editor to strip smart quotes and invisible characters.

Example fix

// before
{"name": "run", 'type': "object",}
// after
{"name": "run", "type": "object"}
Defensive patterns

Strategy: validation

Validate before calling

function isValidJson(s: string): boolean {
  if (!s.trim()) return false;
  try { JSON.parse(s); return true; } catch { return false; }
}
// validate each field before submit and mark invalid fields inline

Type guard

null

Try / catch

try {
  const draft = toDraft(detail, fields);
  await save(draft);
} catch (e) {
  if (e instanceof Error && e.message.endsWith("enter valid JSON.")) {
    setFieldError(e.message.split(" ")[0]); return;
  }
  throw e;
}

Prevention

When it happens

Trigger: Submitting the workflow detail form with malformed JSON in a labeled field — e.g. trailing commas, single quotes, unquoted keys, truncated paste of input/inputSchema/outputSchema — or a required field left empty when optional=false (JSON.parse('' || 'null') yields null, which downstream schema validation may reject).

Common situations: Pasting a schema from a document that mangled quotes, editing JSON by hand and leaving a trailing comma, clearing a required schema field, copying JSON with smart quotes from a chat/markdown renderer, or saving before finishing an edit.

Related errors


AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01). Data as JSON: /api/errors/4205d31c28ebb115. Report an issue: GitHub.