Skip to content

Conversation

@UlisesGascon
Copy link
Member

@UlisesGascon UlisesGascon commented Jun 15, 2025

Related #216

This now can be achieved by running curl -X POST http://localhost:3000/api/v1/workflow/generate-reports/run -H "Content-Type: application/json". Implemented in #241

Summary by CodeRabbit

  • New Features

    • No new features were added in this release.
  • Bug Fixes

    • No bug fixes are included in this release.
  • Documentation

    • Removed documentation for the /api/v1/generate-reports endpoint from the API specification.
  • Refactor

    • Updated workflow execution handling for improved consistency.
  • Chores

    • Removed the /api/v1/generate-reports endpoint and its related tests.

This now can be achieved by running `curl -X POST http://localhost:3000/api/v1/workflow/generate-reports/run   -H "Content-Type: application/json"`
@UlisesGascon UlisesGascon self-assigned this Jun 15, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jun 15, 2025

Walkthrough

This update removes the /api/v1/generate-reports POST endpoint from the API, along with its implementation, OpenAPI documentation, and associated tests. Additionally, the runWorkflow function's signature and its usage in the /workflow/:id/run route are refactored to accept parameters as a single object, and related tests are updated accordingly.

Changes

Files/Paths Change Summary
tests/httpServer/apiV1.test.js Removed tests for /generate-reports endpoint; refactored workflow execution tests to match new signature.
src/httpServer/routers/apiV1.js Removed /generate-reports endpoint and related imports; refactored runWorkflow signature and usage.
src/httpServer/swagger/api-v1.yml Removed OpenAPI documentation for the /generate-reports POST endpoint.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API_Router
    participant WorkflowRunner

    Client->>API_Router: POST /api/v1/workflow/:id/run (with data)
    API_Router->>WorkflowRunner: runWorkflow({workflowName, knex, data})
    WorkflowRunner-->>API_Router: Workflow execution result
    API_Router-->>Client: Response (success or error)
Loading

Possibly related PRs

Poem

The reports have hopped away, no longer in our code,
Workflows now run smoother, in a single object mode.
The docs are lighter, the tests are neat,
With endpoints trimmed, our API’s fleet.
🐇✨
Goodbye old reports—hello, streamlined street!

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (1)
src/httpServer/routers/apiV1.js (1)

95-103: ⚠️ Potential issue

Error message is prefixed twice – remove the second prefix

runWorkflow already wraps failures with Failed to run workflow: ….
The router adds the same prefix again, resulting in messages like
Failed to run workflow: Failed to run workflow: Something went wrong.

-        errors: [{ message: `Failed to run workflow: ${error.message}` }]
+        errors: [{ message: error.message }]

This keeps the response concise and avoids redundant wording.

♻️ Duplicate comments (1)
__tests__/httpServer/apiV1.test.js (1)

219-221: Duplicate of the previous call-argument assertion

Same remark as above; the verification for the failure path mirrors the success path.
If you add the extra check suggested earlier, replicate it here to keep both branches symmetrical.

🧹 Nitpick comments (2)
__tests__/httpServer/apiV1.test.js (1)

185-187: Assertion adapts well to new signature – consider also validating the first arg

👍 The shift from calls[0][0]calls[0][1] correctly reflects the inserted knex parameter.
If feasible, assert that calls[0][0] is indeed a Knex instance to guard against accidental argument re-ordering in future refactors:

expect(mockWorkflowFn.mock.calls[0][0]).toHaveProperty('transaction') // rudimentary Knex shape check
src/httpServer/routers/apiV1.js (1)

10-27: runWorkflow could be simplified & made safer with async/await

The hand-rolled new Promise wrapper plus manual timeout handling works but is unnecessarily verbose and easy to get wrong (e.g. unhandled rejection if workflow.workflow throws synchronously before timeout is set).

Consider refactoring to an async function and leveraging Promise.race for the timeout:

-const runWorkflow = ({ workflowName, knex, data } = {}) => new Promise((resolve, reject) => {
-  const { workflows } = getWorkflowsDetails()
-  const workflow = workflows[workflowName]
-  if (!workflow || typeof workflow.workflow !== 'function') {
-    return reject(new Error('Invalid Workflow'))
-  }
-  const timeout = setTimeout(() => {
-    reject(new Error('Workflow default timeout reached'))
-  }, HTTP_DEFAULT_TIMEOUT)
-
-  Promise.resolve()
-    .then(() => workflow.workflow(knex, data))
-    .then(() => resolve(workflow))
-    .catch(err => reject(new Error(`Failed to run workflow: ${err.message}`)))
-    .finally(() => clearTimeout(timeout))
-})
+async function runWorkflow ({ workflowName, knex, data } = {}) {
+  const { workflows } = getWorkflowsDetails()
+  const wf = workflows[workflowName]
+  if (!wf || typeof wf.workflow !== 'function') {
+    throw new Error('Invalid Workflow')
+  }
+
+  const timeoutPromise = new Promise((_, reject) =>
+    setTimeout(() => reject(new Error('Workflow default timeout reached')), HTTP_DEFAULT_TIMEOUT)
+  )
+
+  await Promise.race([
+    (async () => { await wf.workflow(knex, data) })(),
+    timeoutPromise
+  ])
+
+  return wf
+}

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 5012b928edc888e776b2a77176e0be4cb58ef6de and 2efd18c99cc38872cbd5b0434d0c6a80d6925242.

</details>

<details>
<summary>📒 Files selected for processing (3)</summary>

* `__tests__/httpServer/apiV1.test.js` (2 hunks)
* `src/httpServer/routers/apiV1.js` (3 hunks)
* `src/httpServer/swagger/api-v1.yml` (0 hunks)

</details>

<details>
<summary>💤 Files with no reviewable changes (1)</summary>

* src/httpServer/swagger/api-v1.yml

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (3)</summary>

* GitHub Check: Analyze
* GitHub Check: Playwright Tests
* GitHub Check: build

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

@UlisesGascon UlisesGascon merged commit 3ab3fd1 into main Jun 15, 2025
7 checks passed
@UlisesGascon UlisesGascon added this to the v1.0.0 milestone Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants