Skip to content
1 change: 1 addition & 0 deletions integration-tests/execute/src/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const execute = async (
};
const compiled = compiler(job, options);
const result = await run(compiled.code, state, {
defaultStepId: 'src',
sourceMap: compiled.map,
// preload the linker with some locally installed modules
linker: {
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/execute/test/errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test.serial('should throw a reference error', async (t) => {

t.is(err.message, 'ReferenceError: x is not defined');
t.is(err.severity, 'crash');
t.is(err.step, 'job-1'); // this name is auto-generated btw
t.is(err.step, 'src'); // this name is auto-generated btw
t.deepEqual(err.pos, {
column: 11,
line: 1,
Expand All @@ -40,12 +40,12 @@ test.serial('should throw a type error', async (t) => {
const ignore = ['x'];

const result = await execute(job, state, 'common', ignore);
const err = result.errors['job-1'];
const err = result.errors['src'];
t.log(err.pos);

t.is(err.message, 'TypeError: s is not a function');
t.is(err.severity, 'fail');
t.is(err.step, 'job-1');
t.is(err.step, 'src');
t.deepEqual(err.pos, {
column: 11,
line: 1,
Expand All @@ -65,7 +65,7 @@ test.serial.skip('should throw an adaptor error', async (t) => {
get("www")`;

const result = await execute(job, state, 'http');
const err = result.errors['job-1'];
const err = result.errors['src'];
t.log(err);

t.is(err.message, 'AdaptorError: INVALID_URL');
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/execute/test/execute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ test.serial('catch an error and re-throw it', async (t) => {
}).catch(e => { throw e })`;

const result = await execute(job, state);
t.is(result.errors['job-1'].name, 'JobError');
t.is(result.errors['job-1'].message, 'err');
t.is(result.errors.src.name, 'JobError');
t.is(result.errors.src.message, 'err');
});

test.serial('catch an error and return state', async (t) => {
Expand Down
13 changes: 13 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# @openfn/cli

## 1.20.3

### Patch Changes

- a030ebd: Fix an issue where error positions are not properly reported for named steps in a workflow
- Updated dependencies [a1bfdc1]
- Updated dependencies [c70369b]
- @openfn/runtime@1.7.7
- @openfn/logger@1.1.1
- @openfn/compiler@1.2.2
- @openfn/deploy@0.11.5
- @openfn/project@0.9.3

## 1.20.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/cli",
"version": "1.20.2",
"version": "1.20.3",
"description": "CLI devtools for the OpenFn toolchain",
"engines": {
"node": ">=18",
Expand Down
5 changes: 4 additions & 1 deletion packages/cli/src/compile/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ const compileJob = async (
): Promise<CompiledJob> => {
try {
const compilerOptions: Options = await loadTransformOptions(opts, log);
if (jobName) {
compilerOptions.name = jobName;
}
return compile(job, compilerOptions);
} catch (e: any) {
abort(
Expand Down Expand Up @@ -91,7 +94,7 @@ const compileWorkflow = async (
job.expression as string,
jobOpts,
log,
job.id
job.name ?? job.id
);
job.expression = code;
job.sourceMap = map;
Expand Down
107 changes: 100 additions & 7 deletions packages/cli/test/execute/execute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { ExecuteOptions } from '../../src/execute/command';
import handler from '../../src/execute/handler';
import { mockFs, resetMockFs } from '../util';

// Why is this logging everywhere?
const logger = createMockLogger(undefined, { level: 'none' });

// These options are designed to minimise i/o
Expand All @@ -20,12 +19,8 @@ const defaultOptions = {
repoDir: '/repo',
path: '.',
log: {
// TODO if I pass a mock logger into the handler, the handler then
// goes and creates a real logger and passes it to the runtinme, which
// causes all sorts of logging
// Why isn't that affecting other tests?
// Why do I need this special handling here?
default: 'none',
// This special flag even hides errors
default: 'none-really',
} as any, // TODO some weird typing here
logJson: true,
} as Partial<ExecuteOptions>;
Expand Down Expand Up @@ -129,6 +124,104 @@ test.serial('run a workflow with state', async (t) => {
t.is(result.data.count, 4);
});

test.serial(
'run a workflow with errors and positions with anonymous steps',
async (t) => {
const workflow = {
workflow: {
steps: [
{
expression: `${fn}fn((state) => state.x.length)`,
},
],
},
};

mockFs({
'/workflow.json': JSON.stringify(workflow),
});

const options = {
...defaultOptions,
workflowPath: '/workflow.json',
};
const result = await handler(options, logger);

t.truthy(result.errors);
const err = result.errors['job-1'];
t.regex(err.message, /typeerror: cannot read properties of undefined/i);
t.is(err.pos.line, 2);
t.is(err.pos.column, 23);
}
);

test.serial(
"run a workflow with errors and positions with id'd steps",
async (t) => {
const workflow = {
workflow: {
steps: [
{
id: 'x',
expression: `${fn}fn((state) => state.x.length)`,
},
],
},
};

mockFs({
'/workflow.json': JSON.stringify(workflow),
});

const options = {
...defaultOptions,
workflowPath: '/workflow.json',
};
const result = await handler(options, logger);
t.truthy(result.errors);
t.regex(
result.errors.x.message,
/typeerror: cannot read properties of undefined/i
);
t.is(result.errors.x.pos.line, 2);
t.is(result.errors.x.pos.column, 23);
}
);

test.serial(
'run a workflow with errors and positions and named steps',
async (t) => {
const workflow = {
workflow: {
steps: [
{
id: 'x',
name: 'My Step',
expression: `${fn}fn((state) => state.x.length)`,
},
],
},
};

mockFs({
'/workflow.json': JSON.stringify(workflow),
});

const options = {
...defaultOptions,
workflowPath: '/workflow.json',
};
const result = await handler(options, logger);
t.truthy(result.errors);
t.regex(
result.errors.x.message,
/typeerror: cannot read properties of undefined/i
);
t.is(result.errors.x.pos.line, 2);
t.is(result.errors.x.pos.column, 23);
}
);

test.serial('run a workflow with cached steps', async (t) => {
const workflow = {
workflow: {
Expand Down
7 changes: 7 additions & 0 deletions packages/compiler/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @openfn/compiler

## 1.2.2

### Patch Changes

- Updated dependencies [c70369b]
- @openfn/logger@1.1.1

## 1.2.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/compiler",
"version": "1.2.1",
"version": "1.2.2",
"description": "Compiler and language tooling for openfn jobs.",
"author": "Open Function Group <admin@openfn.org>",
"license": "ISC",
Expand Down
7 changes: 7 additions & 0 deletions packages/deploy/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @openfn/deploy

## 0.11.5

### Patch Changes

- Updated dependencies [c70369b]
- @openfn/logger@1.1.1

## 0.11.4

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/deploy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/deploy",
"version": "0.11.4",
"version": "0.11.5",
"description": "Deploy projects to Lightning instances",
"type": "module",
"exports": {
Expand Down
10 changes: 10 additions & 0 deletions packages/engine-multi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# engine-multi

## 1.9.1

### Patch Changes

- Updated dependencies [a1bfdc1]
- Updated dependencies [c70369b]
- @openfn/runtime@1.7.7
- @openfn/logger@1.1.1
- @openfn/compiler@1.2.2

## 1.9.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/engine-multi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/engine-multi",
"version": "1.9.0",
"version": "1.9.1",
"description": "Multi-process runtime engine",
"main": "dist/index.js",
"type": "module",
Expand Down
10 changes: 10 additions & 0 deletions packages/lightning-mock/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @openfn/lightning-mock

## 2.3.10

### Patch Changes

- Updated dependencies [a1bfdc1]
- Updated dependencies [c70369b]
- @openfn/runtime@1.7.7
- @openfn/logger@1.1.1
- @openfn/engine-multi@1.9.1

## 2.3.9

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/lightning-mock/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/lightning-mock",
"version": "2.3.9",
"version": "2.3.10",
"private": true,
"description": "A mock Lightning server",
"main": "dist/index.js",
Expand Down
6 changes: 6 additions & 0 deletions packages/logger/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @openfn/logger

## 1.1.1

### Patch Changes

- c70369b: Add secret "none-really" log level that even suppresses error logs

## 1.1.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/logger/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/logger",
"version": "1.1.0",
"version": "1.1.1",
"description": "Cross-package logging utility",
"module": "dist/index.js",
"author": "Open Function Group <admin@openfn.org>",
Expand Down
5 changes: 5 additions & 0 deletions packages/logger/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import ensureOptions, { LogOptions, LogLevel } from './options';
// (Note that this doesn't stop a component printing to stdout! It just disables the logger)
export const NONE = 'none';

// Special debug log level - this even hides errors
export const REALLY_NONE = 'none-really';

// Defaults for all the family. Prints what the user absolutely has to know.
// Top-level completions, errors and warnings
export const SUCCESS = 'success'; // aka default
Expand Down Expand Up @@ -113,6 +116,8 @@ const priority: Record<LogFns | LogLevel, number> = {
[SUCCESS]: 2,
[NONE]: 9,
[ERROR]: 100, // errors ALWAYS log

[REALLY_NONE]: 1000,
};

// // TODO I'd quite like each package to have its own colour, I think
Expand Down
2 changes: 1 addition & 1 deletion packages/logger/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SanitizePolicies } from './sanitize';
import defaultEmitter from './util/default-emitter';
import jsonEmitter from './util/json-emitter';

export type LogLevel = 'debug' | 'info' | 'default' | 'none';
export type LogLevel = 'debug' | 'info' | 'default' | 'none' | 'none-really';

export type LogEmitter = typeof console & {
success: typeof console.log;
Expand Down
7 changes: 7 additions & 0 deletions packages/project/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @openfn/project

## 0.9.3

### Patch Changes

- Updated dependencies [c70369b]
- @openfn/logger@1.1.1

## 0.9.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/project/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/project",
"version": "0.9.2",
"version": "0.9.3",
"description": "Read, serialize, replicate and sync OpenFn projects",
"scripts": {
"test": "pnpm ava",
Expand Down
8 changes: 8 additions & 0 deletions packages/runtime/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @openfn/runtime

## 1.7.7

### Patch Changes

- a1bfdc1: Fix an issue where an error can be thrown while trying to source map errors
- Updated dependencies [c70369b]
- @openfn/logger@1.1.1

## 1.7.6

### Patch Changes
Expand Down
Loading