Skip to content

Commit

Permalink
PR feedback - update error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
devhawk committed Jan 23, 2025
1 parent 517f60f commit 666b6c9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions src/dbos-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -663,12 +663,12 @@ export class DBOSExecutor implements DBOSExecutorContext {
const wfStatus = await this.systemDatabase.getWorkflowStatus(workflowUUID);
const wfInputs = await this.systemDatabase.getWorkflowInputs<T>(workflowUUID);
if (!wfStatus || !wfInputs) {
throw new DBOSDebuggerError(`Failed to debug workflow UUID: ${workflowUUID}`);
throw new DBOSDebuggerError(`Failed to find inputs for workflow UUID ${workflowUUID}`);
}

// Make sure we use the same input.
if (DBOSJSON.stringify(args) !== DBOSJSON.stringify(wfInputs)) {
throw new DBOSDebuggerError(`Detect different input for the workflow UUID ${workflowUUID}!\n Received: ${DBOSJSON.stringify(args)}\n Original: ${DBOSJSON.stringify(wfInputs)}`);
throw new DBOSDebuggerError(`Detected different inputs for workflow UUID ${workflowUUID}.\n Received: ${DBOSJSON.stringify(args)}\n Original: ${DBOSJSON.stringify(wfInputs)}`);
}
status = wfStatus.status;
} else {
Expand Down Expand Up @@ -996,7 +996,7 @@ export class DBOSExecutor implements DBOSExecutorContext {
}

if (this.debugMode) {
throw new DBOSDebuggerError(`Failed to debug workflow UUID: ${workflowUUID}`);
throw new DBOSDebuggerError(`Failed to find inputs for workflow UUID ${workflowUUID}`);
}

// For non-read-only transactions, flush the result buffer.
Expand Down Expand Up @@ -1173,7 +1173,7 @@ export class DBOSExecutor implements DBOSExecutorContext {
}

if (this.debugMode) {
throw new DBOSDebuggerError(`Failed to debug workflow UUID: ${wfCtx.workflowUUID}`);
throw new DBOSDebuggerError(`Failed to find inputs for workflow UUID ${wfCtx.workflowUUID}`);
}

// For non-read-only transactions, flush the result buffer.
Expand Down Expand Up @@ -1415,7 +1415,7 @@ export class DBOSExecutor implements DBOSExecutorContext {
}

if (this.debugMode) {
throw new DBOSDebuggerError(`Failed to debug workflow UUID: ${wfCtx.workflowUUID}`);
throw new DBOSDebuggerError(`Failed to find recorded output for workflow UUID: ${wfCtx.workflowUUID}`);
}

// Execute the step function. If it throws an exception, retry with exponential backoff.
Expand Down Expand Up @@ -1573,7 +1573,7 @@ export class DBOSExecutor implements DBOSExecutorContext {
*/
async recoverPendingWorkflows(executorIDs: string[] = ["local"]): Promise<WorkflowHandle<unknown>[]> {
if (this.debugMode) {
throw new DBOSDebuggerError("cannot recover pending workflows in debug mode.");
throw new DBOSDebuggerError("Cannot recover pending workflows in debug mode.");
}

const pendingWorkflows: string[] = [];
Expand Down
18 changes: 9 additions & 9 deletions tests/testing/debugger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ describe("debugger-test", () => {

// Execute a non-exist UUID should fail.
const wfUUID2 = uuidv1();
await expect(debugRuntime.invoke(DebuggerTest, wfUUID2).testWorkflow(username)).rejects.toThrow(`DEBUGGER: Failed to debug workflow UUID: ${wfUUID2}`);
await expect(debugRuntime.invoke(DebuggerTest, wfUUID2).testWorkflow(username)).rejects.toThrow(`DEBUGGER: Failed to find inputs for workflow UUID ${wfUUID2}`);

// Execute a workflow without specifying the UUID should fail.
await expect(debugRuntime.invoke(DebuggerTest).testWorkflow(username)).rejects.toThrow(/DEBUGGER: Failed to debug workflow UUID: [0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/gm);
await expect(debugRuntime.invoke(DebuggerTest).testWorkflow(username)).rejects.toThrow(/DEBUGGER: Failed to find inputs for workflow UUID [0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/gm);
});

test("debug-sleep-workflow", async () => {
Expand Down Expand Up @@ -236,10 +236,10 @@ describe("debugger-test", () => {

// Execute a non-exist UUID should fail.
const wfUUID2 = uuidv1();
await expect(debugRuntime.invoke(DebuggerTest, wfUUID2).testFunction(username)).rejects.toThrow(`DEBUGGER: Failed to debug workflow UUID: ${wfUUID2}`);
await expect(debugRuntime.invoke(DebuggerTest, wfUUID2).testFunction(username)).rejects.toThrow(`DEBUGGER: Failed to find inputs for workflow UUID ${wfUUID2}`);

// Execute a workflow without specifying the UUID should fail.
await expect(debugRuntime.invoke(DebuggerTest).testFunction(username)).rejects.toThrow(/DEBUGGER: Failed to debug workflow UUID: [0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/gm);
await expect(debugRuntime.invoke(DebuggerTest).testFunction(username)).rejects.toThrow(/DEBUGGER: Failed to find inputs for workflow UUID [0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/gm);
});

test("debug-read-only-transaction", async () => {
Expand All @@ -259,10 +259,10 @@ describe("debugger-test", () => {

// Execute a non-exist UUID should fail.
const wfUUID2 = uuidv1();
await expect(debugRuntime.invoke(DebuggerTest, wfUUID2).testReadOnlyFunction(1)).rejects.toThrow(`DEBUGGER: Failed to debug workflow UUID: ${wfUUID2}`);
await expect(debugRuntime.invoke(DebuggerTest, wfUUID2).testReadOnlyFunction(1)).rejects.toThrow(`DEBUGGER: Failed to find inputs for workflow UUID ${wfUUID2}`);

// Execute a workflow without specifying the UUID should fail.
await expect(debugRuntime.invoke(DebuggerTest).testReadOnlyFunction(1)).rejects.toThrow(/DEBUGGER: Failed to debug workflow UUID: [0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/gm);
await expect(debugRuntime.invoke(DebuggerTest).testReadOnlyFunction(1)).rejects.toThrow(/DEBUGGER: Failed to find inputs for workflow UUID [0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/gm);
});

test("debug-step", async () => {
Expand All @@ -281,10 +281,10 @@ describe("debugger-test", () => {

// Execute a non-exist UUID should fail.
const wfUUID2 = uuidv1();
await expect(debugRuntime.invoke(DebuggerTest, wfUUID2).testStep()).rejects.toThrow(`DEBUGGER: Failed to debug workflow UUID: ${wfUUID2}`);
await expect(debugRuntime.invoke(DebuggerTest, wfUUID2).testStep()).rejects.toThrow(`DEBUGGER: Failed to find inputs for workflow UUID ${wfUUID2}`);

// Execute a workflow without specifying the UUID should fail.
await expect(debugRuntime.invoke(DebuggerTest).testStep()).rejects.toThrow(/DEBUGGER: Failed to debug workflow UUID: [0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/gm);
await expect(debugRuntime.invoke(DebuggerTest).testStep()).rejects.toThrow(/DEBUGGER: Failed to find inputs for workflow UUID [0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/gm);

// Make sure we correctly record the function's class name
await dbosExec.flushWorkflowBuffers();
Expand Down Expand Up @@ -333,6 +333,6 @@ describe("debugger-test", () => {
expect(DebuggerTest.cnt).toBe(2);

// Execute again with different input, should still get the same output.
await expect(debugRuntime.invoke(DebuggerTest, wfUUID).diffWorkflow(2)).rejects.toThrow("Detect different input for the workflow");
await expect(debugRuntime.invoke(DebuggerTest, wfUUID).diffWorkflow(2)).rejects.toThrow(/DEBUGGER: Detected different inputs for workflow UUID [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}.\s*Received: \[2\]\s*Original: \[1\]/gm);
})
});

0 comments on commit 666b6c9

Please sign in to comment.