OpenFn / OpenFn/kit

runtime: better errors for implicit globals

Open
#912 0 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

This code:

for (collection of collectGroupArray) { }

Produces an error like this:

R/T SyntaxError: The requested module '@openfn/language-mssql' does not provide an export named 'collection'

collection is an implicit global variable. The compiler generates an import statement, assuming that it will be provided by the adaptor.

But it is not provided by the adaptor! It's a global defined by the code!

The error we get is incomprehensible to users

What can we do?

  • We could try to detect that collection is not a valid import and throw a clearer error earlier
  • We could detect SyntaxErrors of this form/pattern, and add some diagnostic information like "this can happen if you assign to a global variable)

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

Reproduce the example with for (collection of collectGroupArray) { } and trace how the compiler-generated import reaches the runtime. Compare the resulting SyntaxError with the intended implicit-global diagnostic; done means the failure is identified earlier or explained with actionable diagnostic information.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend, compilers
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.