fix/undefined activity#31
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds error handling for undefined activities and services in workflow execution, addressing cases where proxy objects are created with invalid targets or where activity functions don't exist.
- Added validation to prevent proxy creation with non-object targets
- Added runtime checks for undefined activity functions with descriptive error messages
- Included comprehensive test coverage for both undefined service and undefined function scenarios
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/proxy/proxyActivities.ts | Added validation for undefined activities and function existence checks |
| src/tests/workflow-invalid.test.ts | New test file covering undefined service and function error scenarios |
| src/tests/workflow-throws.test.ts | Removed debug console.dir statement from existing test |
| package.json | Version bump from 0.5.3 to 0.5.4 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| const f = activities[activityType]; | ||
| if (!f) { | ||
| throw new Error(`simple-workflows: ${typeof activities}.${activityType} is not a function`); |
There was a problem hiding this comment.
The error message uses typeof activities which will always be 'object' for objects, making the message unclear. Consider using activities.constructor.name or a more descriptive identifier.
Suggested change
| throw new Error(`simple-workflows: ${typeof activities}.${activityType} is not a function`); | |
| throw new Error(`simple-workflows: ${(activities.constructor?.name ?? typeof activities)}.${activityType} is not a function`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.