OpenFn / OpenFn/kit

Worker error: body must be a map

Open
#1,166 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

DevX lost
Dominant language
TypeScript
Stars
21
Forks
23
Avg merge
1d 22h
Merged PRs (30d)
17

Description

This weird error caused a lost run:

✘ e8ed3956-8cc6-4a19-9634-fc57dfdd4823 :: step:complete :: ERR: [step:complete] {"body":["must be a map"]}

link to app

I can only think that somehow the step has sent an invalid structure as the dataclip body

The job code is strange but harmless, so far as I can see (I've tried breaking it down into a repro, but failed)

each('$.cachedData[*]',
    state => Object.entries(state.data.value.rawData),
    fn(state => {
      const [tableName, rows] = state.data;
      
      // Define the order to respect foreign keys
      const insertOrder = ['person', 'patient', 'person_name', 'person_address', 'patient_identifier'];
      
      // Only process if this table is in our current batch
      if (insertOrder.includes(tableName)) {
        console.log(`Processing ${tableName} with ${rows.length} rows`);
        return { ...state, tableName, rows };
      }
      
      console.log(`Skipping ${tableName} - not in insert order`);
      return upsertMany(
      state => state.tableName,
      state => state.rows
    )(state)
    }),
    
  )

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked run and the worker's handling of the step:complete error, then trace where the dataclip body is validated and how the shown job passes state through each(). Determine why an array reaches a path requiring a map, reproduce the failure if possible, and verify that the run no longer fails or loses work.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.