-
Notifications
You must be signed in to change notification settings - Fork 1
feat: update workflow instances based on instance id #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b65f571
e5ff261
2228a65
ecba057
e4a8f50
18c1317
b3a6ea6
cc4f5ca
1ef3930
3c656a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -213,6 +213,26 @@ class ProcessService extends cds.ApplicationService { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return outputs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.on('updateInstanceStatus', async (req: cds.Request) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { instanceId, status } = req.data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LOG.info('Updating instance status', instanceId, '->', status); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LOG.debug( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `==============================================================\n` + | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `Update instance status for ${instanceId} to ${status}\n` + | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `==============================================================`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+216
to
+224
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logic Error: Validation occurs after data is logged, allowing unsanitized/invalid data to be logged before input checks
Consider moving the validation block above the log statements.
Suggested change
Double-check suggestion before committing. Edit this comment for amendments. Please provide feedback on the review comment by checking the appropriate box:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const result = localWorkflowStore.updateStatus(instanceId, status as WorkflowStatus); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!result.success) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LOG.warn(`Workflow instance not found: ${instanceId}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LOG.debug(`Updated status for instance: ${instanceId} to ${status}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return super.init(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Best Practices: The
updateInstanceStatusoperation modifies server-side state (it changes the status of a workflow instance) but is declared as a CDSfunction. In CDS/OData semantics,functionmaps to an HTTP GET (safe, read-only), whileactionmaps to an HTTP POST (non-safe, state-changing). Declaring a state-mutating operation as afunctionviolates OData protocol semantics and may cause caching or proxy issues.Should use
kind: 'action'instead ofkind: 'function'.Double-check suggestion before committing. Edit this comment for amendments.
Please provide feedback on the review comment by checking the appropriate box: