OpenFn / OpenFn/kit

worker: collections adaptor isn't loaded if `collections.get` isn't on one line

Open
#923 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

When the worker loads a Run, it has to decide whether to load the collections adaptor into it.

The test for this is terrible (my fault):

if (job.expression?.match(/(collections\.)/)) {
  hasCollections = true;
}

I did this because I didn't want to do AST parsing just to see if the collections variable is being used. But this is clearly way too brittle

Options:

  • Always load the collections adaptor (does look weird in the run log)
  • Always load the collections adaptor if the word collections appears anywhere (slightly permissive than we have now)
  • Write a better regex (look for whole word collections but not in a comment or string)
  • Use the compiler to preparse and find a "dangling global"

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 by reproducing the worker's Run-loading behavior with a multiline use of collections.get, then inspect how the current collections. match decides whether to load the adaptor. Done means an agreed approach reliably detects the intended usage without the current formatting limitation, with coverage for the reported case.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.