Skip to content

Conversation

@Behzad-rabiei
Copy link
Member

@Behzad-rabiei Behzad-rabiei commented Jul 1, 2025

Summary by CodeRabbit

  • Refactor
    • Simplified workflow execution and termination processes for platform integration, reducing unnecessary checks and standardizing workflow ID management.
    • Improved error handling and logging during workflow termination.
    • Updated method signatures for more consistent usage across the platform.

@coderabbitai
Copy link

coderabbitai bot commented Jul 1, 2025

Walkthrough

The changes simplify workflow management for MediaWiki platforms. Workflow execution now uses a standardized ID format and always runs when the platform is activated, without storing workflow IDs. Workflow termination is also streamlined, using the platform ID to construct the workflow ID internally. Logging and document updates were removed.

Changes

File(s) Change Summary
src/services/module.service.ts Simplified handleHivemindMediaWikiCase: removed workflow ID checks, logging, and document updates; now always executes or terminates workflow based on platform activation.
src/services/temporal/mediaWiki.service.ts Standardized workflow ID format; executeWorkflow and terminateWorkflow now use platform ID directly; removed logging and workflow handle returns; simplified termination logic.

Sequence Diagram(s)

sequenceDiagram
    participant ModuleService
    participant TemporalMediaWikiService

    alt Platform Activated
        ModuleService->>TemporalMediaWikiService: executeWorkflow(platformId)
    else Platform Deactivated
        ModuleService->>TemporalMediaWikiService: terminateWorkflow(platformId)
    end
Loading

Possibly related PRs

Poem

A bunny hopped through code today,
Tidying workflows in a streamlined way.
No more clutter, IDs are neat,
Simpler logic—oh, what a treat!
With every hop, the process shines,
As MediaWiki now aligns.
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-07-01T06_35_24_931Z-debug-0.log

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

@Behzad-rabiei Behzad-rabiei merged commit e81a1ac into main Jul 1, 2025
3 checks passed
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: 4

🧹 Nitpick comments (1)
src/services/temporal/mediaWiki.service.ts (1)

2-2: Remove unused import.

The uuid import is no longer needed since the workflow ID format was changed to deterministic.

Apply this diff to remove the unused import:

-import { v4 as uuidv4 } from 'uuid';
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2f5ebe5 and bb4b85b.

📒 Files selected for processing (2)
  • src/services/module.service.ts (1 hunks)
  • src/services/temporal/mediaWiki.service.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/services/module.service.ts (2)
Learnt from: Behzad-rabiei
PR: TogetherCrew/api#350
File: src/services/module.service.ts:55-71
Timestamp: 2024-10-09T08:57:20.287Z
Learning: Error handling for the `updateModule` function in `src/services/module.service.ts` is managed by the parent function, as indicated by user Behzad-rabiei.
Learnt from: Behzad-rabiei
PR: TogetherCrew/api#350
File: src/services/module.service.ts:55-71
Timestamp: 2024-07-27T19:38:44.885Z
Learning: Error handling for the `updateModule` function in `src/services/module.service.ts` is managed by the parent function, as indicated by user Behzad-rabiei.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: ci / build-push / Build + Push Image
🔇 Additional comments (2)
src/services/temporal/mediaWiki.service.ts (1)

20-20: Verify deterministic workflow ID won’t block concurrent runs

Using a fixed ID format api:mediawikietl:${platformId} means only one workflow per platform can run at a time. If your system ever needs to start multiple MediaWiki ETL workflows for the same platformId in parallel (e.g., retries, backfills, overlapping triggers), they will collide.

Please confirm whether you ever need concurrent workflows per platform. If so, consider one of the following:

  • Append a unique suffix (UUID, timestamp) to the ID:
    workflowId: `api:mediawikietl:${platformId}:${uuid()}`,
  • Revert to letting Temporal generate a random ID (omit workflowId)
  • Use tags or memo fields to identify workflows by platform while keeping unique IDs

Location needing attention:
• src/services/temporal/mediaWiki.service.ts — line defining workflowId

src/services/module.service.ts (1)

149-153: LGTM! Simplified workflow management.

The simplified logic that directly calls the temporal service methods based on activation status is much cleaner than the previous implementation. The removal of workflow ID management aligns well with the standardized ID format in the temporal service.

if (description.status.name !== 'TERMINATED' && description.status.name !== 'COMPLETED') {
await handle.terminate('Terminated due to schedule deletion');
try {
client.workflow.getHandle(`api:mediawikietl:${platformId}`).terminate();
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Missing await for workflow termination.

The workflow termination is not awaited, which means the method will return before the termination completes. This could lead to inconsistent state or ineffective error handling.

Apply this diff to fix the async operation:

-      client.workflow.getHandle(`api:mediawikietl:${platformId}`).terminate();
+      await client.workflow.getHandle(`api:mediawikietl:${platformId}`).terminate();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
client.workflow.getHandle(`api:mediawikietl:${platformId}`).terminate();
await client.workflow.getHandle(`api:mediawikietl:${platformId}`).terminate();
🤖 Prompt for AI Agents
In src/services/temporal/mediaWiki.service.ts at line 31, the call to terminate
the workflow handle is missing an await, causing the method to return before the
termination completes. Add the await keyword before
client.workflow.getHandle(...).terminate() to ensure the termination completes
before proceeding, enabling proper error handling and consistent state.

Comment on lines +17 to 21
client.workflow.execute('MediaWikiETLWorkflow', {
taskQueue: queues.TEMPORAL_QUEUE_PYTHON_HEAVY,
args: [payload],
workflowId: `mediawiki/${platformId}/${uuidv4()}`,
workflowId: `api:mediawikietl:${platformId}`,
});
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Missing await for workflow execution.

The workflow execution is not awaited, which means the method will return immediately without waiting for the workflow to start. This could lead to race conditions or make error handling ineffective.

Apply this diff to fix the async operation:

-      client.workflow.execute('MediaWikiETLWorkflow', {
+      await client.workflow.execute('MediaWikiETLWorkflow', {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
client.workflow.execute('MediaWikiETLWorkflow', {
taskQueue: queues.TEMPORAL_QUEUE_PYTHON_HEAVY,
args: [payload],
workflowId: `mediawiki/${platformId}/${uuidv4()}`,
workflowId: `api:mediawikietl:${platformId}`,
});
await client.workflow.execute('MediaWikiETLWorkflow', {
taskQueue: queues.TEMPORAL_QUEUE_PYTHON_HEAVY,
args: [payload],
workflowId: `api:mediawikietl:${platformId}`,
});
🤖 Prompt for AI Agents
In src/services/temporal/mediaWiki.service.ts around lines 17 to 21, the call to
client.workflow.execute is missing an await, causing the method to return
immediately without waiting for the workflow to start. To fix this, add the
await keyword before client.workflow.execute to ensure the workflow execution is
properly awaited and errors can be handled effectively.

}
temporalMediaWiki.executeWorkflow(platformDoc.id);
} else if (isActivated === false) {
temporalMediaWiki.terminateWorkflow(platformDoc.id);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Missing await for workflow termination.

The workflow termination call is not awaited, which could lead to the function returning before the workflow is actually terminated. This may cause issues if the platform state depends on the workflow being stopped.

Apply this diff to fix the async operation:

-    temporalMediaWiki.terminateWorkflow(platformDoc.id);
+    await temporalMediaWiki.terminateWorkflow(platformDoc.id);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
temporalMediaWiki.terminateWorkflow(platformDoc.id);
await temporalMediaWiki.terminateWorkflow(platformDoc.id);
🤖 Prompt for AI Agents
In src/services/module.service.ts at line 152, the call to
temporalMediaWiki.terminateWorkflow(platformDoc.id) is missing an await, causing
the function to potentially return before the workflow termination completes.
Add the await keyword before the call to ensure the workflow termination
finishes before proceeding.

platformDoc.set('metadata.workflowId', workflowId);
await platformDoc.save();
}
temporalMediaWiki.executeWorkflow(platformDoc.id);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Missing await for workflow execution.

The workflow execution call is not awaited, which could lead to the function returning before the workflow starts. This may cause issues if subsequent operations depend on the workflow being active.

Apply this diff to fix the async operation:

-    temporalMediaWiki.executeWorkflow(platformDoc.id);
+    await temporalMediaWiki.executeWorkflow(platformDoc.id);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
temporalMediaWiki.executeWorkflow(platformDoc.id);
await temporalMediaWiki.executeWorkflow(platformDoc.id);
🤖 Prompt for AI Agents
In src/services/module.service.ts at line 150, the call to
temporalMediaWiki.executeWorkflow(platformDoc.id) is missing an await, causing
the function to potentially return before the workflow starts. Add the await
keyword before temporalMediaWiki.executeWorkflow to ensure the workflow
execution completes or starts before proceeding.

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