OpenFn / OpenFn/kit

Guard id lookups against built-in object properties

Open
#1,513 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

We use plain objects as lookup tables keyed by step and workflow ids, and a few names are already properties of every JavaScript object, so a lookup returns a built-in instead of nothing.

Three things follow, all reproduced. A step named constructor is reported to Lightning as failed when it succeeded, because calculateJobExitReason in packages/ws-worker/src/api/reasons.ts reads state.errors[jobId] and gets the Object function. A step named __proto__ is dropped from the plan in compile-plan.ts and never runs, silently. An adaptor named constructor crashes autoinstall with a type error rather than failing cleanly.

Step ids arrive from Lightning unchecked, so none of this needs a hand-edited file.

The first one is worth a note because it fooled me twice. state.errors is built with Object.create(null), so it reads as safe. But it crosses process.send on the way out of the worker pool, and that trip serialises it to JSON and hands back an ordinary object with the built-ins restored. A comment claiming it is safe by construction is only true on one side of that boundary.

Fixing these one site at a time has not gone well elsewhere, so it is probably worth deciding how to stop it recurring rather than only where it is now.

Came up while investigating lightning#4577, though none of it is about Unicode.

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 calculateJobExitReason in packages/ws-worker/src/api/reasons.ts, then inspect compile-plan.ts and the autoinstall path. Trace how state.errors crosses process.send and is serialized, and reproduce the constructor and proto cases. Done means step and adaptor ids cannot resolve to built-in object properties and invalid lookups fail cleanly across all three sites.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.