Skip to content

Conversation

@UlisesGascon
Copy link
Member

@UlisesGascon UlisesGascon commented Jun 15, 2025

Related #216

image

Summary by CodeRabbit

  • New Features

    • Added a new API endpoint to execute workflows by ID via POST request.
    • Enhanced API documentation to include the new workflow execution endpoint.
  • Improvements

    • Workflow listing and execution endpoints now provide more detailed and structured workflow information.
    • The workflow import function now supports importing data directly or from a file path.
  • Tests

    • Expanded test coverage for workflow execution scenarios, including success, errors, and timeouts.

@coderabbitai
Copy link

coderabbitai bot commented Jun 15, 2025

Warning

Rate limit exceeded

@UlisesGascon has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 52 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 9cccd4e and e8a63be.

📒 Files selected for processing (2)
  • src/httpServer/routers/apiV1.js (2 hunks)
  • src/importers/index.js (1 hunks)

Walkthrough

The changes introduce a new POST endpoint to execute workflows via the API, update the workflow retrieval and execution logic to use a new details function, and enhance test coverage for workflow execution scenarios. The API specification and importer function signatures are updated to reflect these changes, supporting both file path and direct data input.

Changes

File(s) Summary
src/httpServer/routers/apiV1.js Replaces getAllWorkflows with getWorkflowsDetails, adds runWorkflow helper, and implements POST /workflow/:id/run endpoint with timeout logic. Updates GET /workflow to new workflow details structure.
src/httpServer/swagger/api-v1.yml Adds POST /api/v1/workflow/{workflowId}/run endpoint to OpenAPI spec, defining request/response schemas and error handling.
src/cli/workflows.js Replaces exported getAllWorkflows with getWorkflowsDetails, introduces kebab-case workflow keys, and updates internal workflow structure.
src/importers/index.js Updates bulkImport to accept either a file path or direct data, adjusting logic to handle both cases.
tests/httpServer/apiV1.test.js Adds and updates tests for GET /workflow and new POST /workflow/:id/run endpoint, including success, not found, error, and timeout scenarios.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API_Server
    participant Workflows_Module

    Client->>API_Server: POST /api/v1/workflow/{id}/run (with data)
    API_Server->>Workflows_Module: getWorkflowsDetails()
    API_Server->>API_Server: Validate workflow ID
    alt Workflow found
        API_Server->>Workflows_Module: Run workflow function with data (with timeout)
        alt Workflow completes
            API_Server-->>Client: 202 Accepted (status: completed, workflow details)
        else Workflow fails
            API_Server-->>Client: 500 Internal Server Error (status: failed, error)
        end
    else Workflow not found
        API_Server-->>Client: 404 Not Found (error message)
    end
Loading

Possibly related PRs

  • feat: add GET /api/v1/workflow endpoint #240: Adds the GET /workflow endpoint using the older getAllWorkflows function; related as the current PR extends this by adding POST /workflow/:id/run and switching to getWorkflowsDetails.

Poem

Hopping through the code today,
New workflows now can run and play!
With POST and test, we check each case,
From happy path to error's face.
Importers flex with data new,
And rabbits cheer this clever crew!
🐇✨

✨ 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.

@UlisesGascon UlisesGascon self-assigned this Jun 15, 2025
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: 3

🧹 Nitpick comments (4)
src/cli/workflows.js (1)

37-48: Avoid shadowing & favour expressive naming

The local constant workflows hides the public-facing variable you’re about to return. A more explicit name (e.g. workflowsMap) prevents any mental gymnastics when reading the code and avoids accidental confusion with the top-level commandList.

-  const workflows = {}
+  const workflowsMap = {}
   const workflowsList = []

   commandList.forEach((workflow) => {
     const workflowName = _.kebabCase(workflow.name)
     workflowsList.push({ id: workflowName, description: workflow.description })
-    workflows[workflowName] = {
+    workflowsMap[workflowName] = {
       description: workflow.description,
       workflow: workflow.workflow
     }
   })

-  return { workflows, workflowsList }
+  return { workflows: workflowsMap, workflowsList }
__tests__/httpServer/apiV1.test.js (1)

6-21: Duplicate mocks hide errors

mockWorkflowFn is declared twice – once at file scope (line 6) and again inside the POST-workflow beforeEach (line 153).
If a test outside that describe block unexpectedly relies on the outer mock, its call-count assertions will silently break.

Delete the top-level declaration and keep the per-suite version (or hoist the inner one).
This keeps mock state local and predictable.

src/httpServer/routers/apiV1.js (1)

76-105: OpenAPI mismatch & double lookup

  1. getWorkflowsDetails() is invoked once to build workflows, then again inside runWorkflow(). Pass the resolved map into runWorkflow() (or curry the function) to avoid redundant work.

  2. The error payload uses workflow.description when the workflow might be undefined; this is covered by the ternary but can be simplified by returning early.

src/httpServer/swagger/api-v1.yml (1)

81-87: Path parameter naming drift

Express route is /workflow/:id/run (param id) but the spec defines {workflowId}.
Keep them consistent to avoid confusion in autogenerated clients.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e6a8bd7 and 9c59a4a.

📒 Files selected for processing (5)
  • __tests__/httpServer/apiV1.test.js (3 hunks)
  • src/cli/workflows.js (3 hunks)
  • src/httpServer/routers/apiV1.js (2 hunks)
  • src/httpServer/swagger/api-v1.yml (1 hunks)
  • src/importers/index.js (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/cli/workflows.js (3)
__tests__/httpServer/apiV1.test.js (1)
  • getWorkflowsDetails (31-31)
src/cli/index.js (1)
  • workflows (2-2)
visionboard.js (1)
  • workflow (35-37)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Playwright Tests
🔇 Additional comments (1)
__tests__/httpServer/apiV1.test.js (1)

148-172: Consider testing the timeout branch

A TODO already exists, but note that runWorkflow() rejects after 30 s by default.
Use jest.useFakeTimers() and advance the timers to assert the 500 path without waiting in real time.

@UlisesGascon UlisesGascon force-pushed the ulises/v1-run-workflow branch 3 times, most recently from 83382a9 to 6b025b9 Compare June 15, 2025 17:20
@UlisesGascon UlisesGascon force-pushed the ulises/v1-run-workflow branch from 6b025b9 to e8a63be Compare June 15, 2025 17:24
@UlisesGascon UlisesGascon merged commit 5012b92 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