Inconsistent behavior with `cursor` function syntax
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 24
- Forks
- 41
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 12
Description
Description:
I encountered an issue with the cursor function where two syntactically similar usages produce different results. The first usage works as expected, while the second one does not.
Working Code:
cursor((state) => state.manualCursor, { defaultValue: (state) => state.lastRunDateTime || 'now' })
CLI logs for working code
[CLI] ♦ Versions:
▸ node.js 18.17.1
▸ cli 1.2.2
▸ @openfn/language-common monorepo
[CLI] ✔ Loading adaptors from monorepo at /Users/openfn/Workspace/adaptors
[CLI] ⚠ Skipping auto-install as monorepo is being used
[CLI] ✔ Loaded state from tmp/state.json
[CLI] ✔ Compiled all expressions in workflow
Setting cursor "now" to: 16:06 4 Jun 2024 (GMT+3)
[R/T] ✔ Completed step job-1 in 190ms
[CLI] ✔ State written to tmp/output.json
[CLI] ✔ Finished in 263ms ✨
Non-working Code:
cursor(state => state.manualCursor, state => ({
defaultValue: state.lastRunDateTime || 'now'
}))
// Lazy load equivalent
cursor($.manualCursor, { defaultValue: $.lastRunDateTime || 'now' });
CLI Logs for Non-working code
[CLI] ♦ Versions:
▸ node.js 18.17.1
▸ cli 1.2.2
▸ @openfn/language-common monorepo
[CLI] ✔ Loading adaptors from monorepo at /Users/openfn/Workspace/adaptors
[CLI] ⚠ Skipping auto-install as monorepo is being used
[CLI] ✔ Loaded state from tmp/state.json
[CLI] ✔ Compiled all expressions in workflow
Setting cursor to: undefined
[R/T] ✔ Completed step job-1 in 246ms
[CLI] ✔ State written to tmp/output.json
[CLI] ✔ Finished in 318ms ✨
Steps to Reproduce:
- Run the job with working code with initial state as
{}. It will print in CLI logsSetting cursor "now" to: HH:mm D M YYY - Run the job with non-working code with initial state as
{}. It will print in CLI logsSetting cursor "now" to: undefined
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the cursor function and comparing the two JavaScript call forms shown in the issue. Reproduce both with initial state {} using the CLI and the listed versions; done means equivalent forms resolve the cursor consistently instead of producing undefined.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100