DEV Community

Flowpaja
Flowpaja

Posted on Originally published at flowpaja.com

Debug Make JSON by Checking the Boundary First

Some links are affiliate links. If you sign up, Flowpaja may earn a commission at no extra cost to you.

A red Parse JSON module invites a syntax hunt. Before looking for a trailing comma, establish whether the module received JSON text at all. An empty value, malformed text and an already parsed collection can fail at the same boundary while requiring different changes.

Imagine a small intake workflow with a webhook, an optional lookup and a Google Sheets write. The JSON parser sits between the lookup and the write because it was useful in an earlier version. The scenario has since changed. Keeping the parser on the canvas does not establish that its input is still text.

The fastest investigation follows the value across one boundary: the previous module's output and the parser's actual input. Work from a saved failing execution. A mapping token shows what you intended to select; the execution shows what arrived.

Classify the input before repairing it

Read the exact error. Missing value of required parameter 'json' points to absent input in the required JSON string field. Source is not valid JSON means the supplied value did not parse as strict JSON. Do not treat the messages as interchangeable.

Open the previous module's output. Is there a text value containing braces or brackets? Is it blank? Is the relevant output already a collection with named fields? Write down that classification before changing either module.

This is also why a module-only test can mislead you. Running the parser alone does not automatically execute every upstream producer. If its mapped field depends on those outputs, test with Run once through the full route, or supply explicit sample text for the isolated test.

Make absence an explicit branch

An HTTP response can legitimately have no body. An optional form answer can be absent. A lookup can find no record. Each case needs a policy before a required parser field is evaluated.

If the lookup is Google Sheets Search Rows, remember its specific behavior: no match produces one empty bundle whose Total number of bundles is zero. Put a numeric filter on that count before trying to parse a JSON cell. A matched-row route uses a count greater than zero; where a key is supposed to be unique, investigate multiple matches rather than quietly parsing an arbitrary row.

An empty object fallback is appropriate only when an empty object is a meaningful downstream input. Replacing a missing lead payload with an empty object may silence the parser and create a blank row later. Stop or review the bundle when missing input means the workflow cannot complete honestly.

Remap a stale token from the current upstream output. A token referring to a replaced module or a question that no longer exists can remain on the canvas while evaluating to nothing.

Check whether parsing already happened

A Custom webhook receiving JSON can expose the request as mapped fields. Similarly, an HTTP response parsed by the HTTP module can arrive as structured data. A collection is not the same thing as the original JSON string.

If the needed fields already exist, map them directly into the next action and remove the redundant parser from that path. Keep Parse JSON for a boundary that actually carries text needing interpretation. Make's JSON app reference distinguishes creating JSON text from parsing it.

Do a small end-to-end test after removing the parser. Confirm the email and name reaching Add a Row, rather than assuming the visible mapper field names prove the values. A correct type at one boundary does not guarantee you selected the correct nested item.

Repair the producer of malformed text

Now consider genuine JSON text that fails. Compare a tiny valid fixture with the exact failing value:

{"email":"morgan@example.invalid","message":"Please reply after lunch"}
Enter fullscreen mode Exit fullscreen mode

A trailing comma, single-quoted keys, curly quotation marks or explanatory prose around the object can invalidate that text. Test with fictional data locally or in a scratch scenario. Do not paste customer payloads into an unrelated online validator.

If a model or another text producer wraps its result in Markdown fences, make the producer's output contract strict JSON where supported. Removing known fences can be a narrowly tested fallback; it does not validate arbitrary prose or guarantee the producer's object has the required fields.

For mapped user answers, use Create JSON with a matching data structure rather than interpolating answers into a hand-written string. Quotes and line breaks are legitimate parts of an answer. The serializer should escape them; the workflow should not delete them to satisfy the parser.

Keep transport failures at the transport boundary

If the value begins with HTML, investigate the HTTP response before adjusting the JSON schema. A login page or error page is evidence of an endpoint, authentication or request problem.

For an HTTP request that should fail on a non-success response, set Return error if HTTP request fails to Yes. Then inspect the actual status, endpoint and response body. A 200 response with an unexpected HTML body still deserves investigation; enabling that setting does not guarantee the content is JSON.

Keep authentication values out of screenshots and shared troubleshooting files. Record the response shape and useful error text, then test the repaired request against a disposable resource where possible.

Test schema and bundle shape after syntax

Syntactically valid JSON can still be the wrong contract. An object with email missing is different from the expected object. A number represented as text can pass parsing while failing a later numeric field. Inspect the parsed output and the destination input separately.

A top-level array also changes the workflow's shape. Parse JSON can output an item as a separate bundle, causing subsequent actions to run for every item. Test two fictional items and count the actual rows or messages produced. If the goal is one digest, use aggregation for that real list, with the correct source module. Do not use aggregation to infer that a Sheets search found no rows.

Finally, replay the original failure after repairing its cause. Retry repeats work; it cannot repair unchanged invalid text. Skip omits the bundle, and Resume supplies substitute output. Those choices need a business rule, not just a desire for a green execution.

The free webhook-to-Sheets template is a useful related starting point when intake arrives as JSON fields and needs a request-ID duplicate check. Read the full parser guide for the diagnostic variants. To create a scratch scenario, start with Make and keep the test data fictional.

Further reading

Top comments (0)