Skip to content

Conversation

@anatolyshipitz
Copy link
Collaborator

@anatolyshipitz anatolyshipitz commented Dec 4, 2025

  • Added a new function setupWeeklyReportSchedule in schedules.ts to create a weekly schedule for financial reports, running every Tuesday at 1 PM EST/EDT.
  • Integrated the schedule setup into the worker's run function in index.ts, ensuring it is established before the worker starts.
  • Enhanced error handling during schedule setup to log failures appropriately.

These changes improve the automation of financial reporting, ensuring timely execution of workflows.

Summary by CodeRabbit

  • New Features
    • Automatic weekly financial report scheduling — runs Tuesdays at 1:00 PM ET, timezone-aware, non-overlapping with a 1-day catch-up window; scheduling now runs during startup before the worker begins.
  • Documentation
    • Added guidance for connecting to the scheduling system and configuring the weekly schedule and startup behavior.
  • Refactor
    • Startup and logging flow reorganized to centralize initialization and improve operational logging.

✏️ Tip: You can customize this high-level summary in your review settings.

…tion

- Added a new function `setupWeeklyReportSchedule` in `schedules.ts` to create a weekly schedule for financial reports, running every Tuesday at 1 PM EST/EDT.
- Integrated the schedule setup into the worker's `run` function in `index.ts`, ensuring it is established before the worker starts.
- Enhanced error handling during schedule setup to log failures appropriately.

These changes improve the automation of financial reporting, ensuring timely execution of workflows.
@github-actions
Copy link

github-actions bot commented Dec 4, 2025

CodeRabbit CodeRabbit

🤖 CodeRabbit AI Review Available

To request a code review from CodeRabbit AI, add [coderabbit-ai-review] to your PR title.

CodeRabbit will analyze your code and provide feedback on:

  • Logic and correctness
  • Security issues
  • Performance optimizations
  • Code quality and best practices
  • Error handling
  • Maintainability

Note: Reviews are only performed when [coderabbit-ai-review] is present in the PR title.

@coderabbitai
Copy link

coderabbitai bot commented Dec 4, 2025

Warning

Rate limit exceeded

@anatolyshipitz has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 22 minutes and 30 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 7b07b52 and 6594469.

📒 Files selected for processing (1)
  • workers/main/src/configs/schedules.ts (1 hunks)

Walkthrough

Adds a new schedule module and startup wiring that ensures a weekly Temporal schedule (cron 0 13 * * 2, timezone America/New_York) exists to start weeklyFinancialReportsWorkflow before the worker is created and run; extracts a shared logger and adds temporal config docs.

Changes

Cohort / File(s) Summary
Schedule configuration
workers/main/src/configs/schedules.ts
New file exporting setupWeeklyReportSchedule(client: Client): Promise<void> which checks for an existing schedule (describe) and creates it if missing with cron 0 13 * * 2, timezone America/New_York, action startWorkflow -> weeklyFinancialReportsWorkflow (workflowId weekly-financial-report-scheduled), policies: overlap SKIP, catchupWindow 1 day. Also exports scheduleConfig constant with metadata.
Worker startup / orchestration
workers/main/src/index.ts
Reworks startup: adds createConnection, createWorker, run, handleRunError, and mainEntry; performs schedule setup via a temporary Client/Connection before creating and running the worker; re-exports logger from ./logger.
Logger extraction
workers/main/src/logger.ts
New file exporting a shared logger instance (DefaultLogger('INFO')) used by the worker and startup code.
Docs only
workers/main/src/configs/temporal.ts
Added/updated documentation blocks describing Temporal connection configuration and the weekly schedule; no functional changes.
Tests import update
workers/main/src/index.test.ts
Test updated to import logger from ./logger instead of ./index; other test logic unchanged.

Sequence Diagram(s)

sequenceDiagram
    participant App as Application (startup)
    participant Conn as NativeConnection
    participant Client as Temporal Client
    participant Svc as schedules.ts
    participant Worker as Temporal Worker

    App->>Conn: Connection.connect(temporalConfig)
    Conn->>Client: Client created using connection
    App->>Svc: setupWeeklyReportSchedule(Client)
    Svc->>Client: getHandle(scheduleId) / describe()
    alt schedule exists
        Svc-->>App: log exists & return
    else schedule missing
        Svc->>Client: createSchedule({cron: "0 13 * * 2", timezone: "America/New_York", action: startWorkflow weeklyFinancialReportsWorkflow, policies})
        Svc-->>App: log success
    end
    App->>Worker: createWorker(connection)
    App->>Worker: worker.run()
    Note right of Worker: At scheduled time → Client triggers workflow start → Worker executes weeklyFinancialReportsWorkflow
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Inspect schedule create/describe logic and Temporal handle usage in schedules.ts
  • Verify cron, timezone, policy settings, and workflow start action (ensure args/signature match weeklyFinancialReportsWorkflow)
  • Confirm proper lifecycle: temporary client connect/close in index.ts and error handling paths
  • Review logger level and its usage across startup, worker, and tests

Possibly related PRs

Suggested reviewers

  • killev

Poem

🐇 I nudged the cron to Tuesday noon,
I pat the logs and hum a tune,
I hop, I sprint, the schedule springs,
Tiny paws that fetch reporty things,
Carrots, metrics, and soft drum tunes — 🥕📊

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Implement weekly financial report schedule' directly summarizes the main change: adding a new scheduling function for weekly financial reports that runs every Tuesday at 1 PM EST/EDT, integrated into the worker startup process.

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

Comment @coderabbitai help to get the list of available commands and usage tips.

- Improved error handling in the `setupWeeklyReportSchedule` function by capturing and logging the error message when a schedule creation fails.
- Updated log message to include the specific error encountered, aiding in debugging and monitoring.

These changes enhance the visibility of issues during schedule setup, facilitating quicker resolution of potential problems.
@github-actions
Copy link

github-actions bot commented Dec 4, 2025

🔍 Vulnerabilities of temporal-test:latest

📦 Image Reference temporal-test:latest
digestsha256:17e54ff5e9a181d1bdbf7334ce9637f9c3934d54a65427ae36a5743f46487f15
vulnerabilitiescritical: 2 high: 23 medium: 0 low: 0
platformlinux/amd64
size218 MB
packages358
📦 Base Image alpine:3
also known as
  • 3.21
  • 3.21.3
  • latest
digestsha256:1c4eef651f65e2f7daee7ee785882ac164b02b78fb74503052a26dc061c90474
vulnerabilitiescritical: 0 high: 1 medium: 2 low: 2
critical: 1 high: 5 medium: 0 low: 0 stdlib 1.23.2 (golang)

pkg:golang/stdlib@1.23.2

critical : CVE--2025--22871

Affected range<1.23.8
Fixed version1.23.8
EPSS Score0.025%
EPSS Percentile6th percentile
Description

The net/http package improperly accepts a bare LF as a line terminator in chunked data chunk-size lines. This can permit request smuggling if a net/http server is used in conjunction with a server that incorrectly accepts a bare LF as part of a chunk-ext.

high : CVE--2025--61729

Affected range<1.24.11
Fixed version1.24.11
EPSS Score0.012%
EPSS Percentile1st percentile
Description

Within HostnameError.Error(), when constructing an error string, there is no limit to the number of hosts that will be printed out. Furthermore, the error string is constructed by repeated string concatenation, leading to quadratic runtime. Therefore, a certificate provided by a malicious actor can result in excessive resource consumption.

high : CVE--2025--61725

Affected range<1.24.8
Fixed version1.24.8
EPSS Score0.026%
EPSS Percentile6th percentile
Description

The ParseAddress function constructeds domain-literal address components through repeated string concatenation. When parsing large domain-literal components, this can cause excessive CPU consumption.

high : CVE--2025--61723

Affected range<1.24.8
Fixed version1.24.8
EPSS Score0.026%
EPSS Percentile6th percentile
Description

The processing time for parsing some invalid inputs scales non-linearly with respect to the size of the input.

This affects programs which parse untrusted PEM inputs.

high : CVE--2025--58188

Affected range<1.24.8
Fixed version1.24.8
EPSS Score0.014%
EPSS Percentile2nd percentile
Description

Validating certificate chains which contain DSA public keys can cause programs to panic, due to a interface cast that assumes they implement the Equal method.

This affects programs which validate arbitrary certificate chains.

high : CVE--2025--58187

Affected range<1.24.9
Fixed version1.24.9
EPSS Score0.014%
EPSS Percentile2nd percentile
Description

Due to the design of the name constraint checking algorithm, the processing time of some inputs scale non-linearly with respect to the size of the certificate.

This affects programs which validate arbitrary certificate chains.

critical: 1 high: 5 medium: 0 low: 0 stdlib 1.23.6 (golang)

pkg:golang/stdlib@1.23.6

critical : CVE--2025--22871

Affected range<1.23.8
Fixed version1.23.8
EPSS Score0.025%
EPSS Percentile6th percentile
Description

The net/http package improperly accepts a bare LF as a line terminator in chunked data chunk-size lines. This can permit request smuggling if a net/http server is used in conjunction with a server that incorrectly accepts a bare LF as part of a chunk-ext.

high : CVE--2025--61729

Affected range<1.24.11
Fixed version1.24.11
EPSS Score0.012%
EPSS Percentile1st percentile
Description

Within HostnameError.Error(), when constructing an error string, there is no limit to the number of hosts that will be printed out. Furthermore, the error string is constructed by repeated string concatenation, leading to quadratic runtime. Therefore, a certificate provided by a malicious actor can result in excessive resource consumption.

high : CVE--2025--61725

Affected range<1.24.8
Fixed version1.24.8
EPSS Score0.026%
EPSS Percentile6th percentile
Description

The ParseAddress function constructeds domain-literal address components through repeated string concatenation. When parsing large domain-literal components, this can cause excessive CPU consumption.

high : CVE--2025--61723

Affected range<1.24.8
Fixed version1.24.8
EPSS Score0.026%
EPSS Percentile6th percentile
Description

The processing time for parsing some invalid inputs scales non-linearly with respect to the size of the input.

This affects programs which parse untrusted PEM inputs.

high : CVE--2025--58188

Affected range<1.24.8
Fixed version1.24.8
EPSS Score0.014%
EPSS Percentile2nd percentile
Description

Validating certificate chains which contain DSA public keys can cause programs to panic, due to a interface cast that assumes they implement the Equal method.

This affects programs which validate arbitrary certificate chains.

high : CVE--2025--58187

Affected range<1.24.9
Fixed version1.24.9
EPSS Score0.014%
EPSS Percentile2nd percentile
Description

Due to the design of the name constraint checking algorithm, the processing time of some inputs scale non-linearly with respect to the size of the certificate.

This affects programs which validate arbitrary certificate chains.

critical: 0 high: 2 medium: 0 low: 0 golang.org/x/crypto 0.32.0 (golang)

pkg:golang/golang.org/x/crypto@0.32.0

high : CVE--2025--47913

Affected range<0.43.0
Fixed version0.43.0
EPSS Score0.018%
EPSS Percentile4th percentile
Description

SSH clients receiving SSH_AGENT_SUCCESS when expecting a typed response will panic and cause early termination of the client process.

high : CVE--2025--22869

Affected range<0.35.0
Fixed version0.35.0
EPSS Score0.217%
EPSS Percentile44th percentile
Description

SSH servers which implement file transfer protocols are vulnerable to a denial of service attack from clients which complete the key exchange slowly, or not at all, causing pending content to be read into memory, but never transmitted.

critical: 0 high: 2 medium: 0 low: 0 curl 8.12.1-r0 (apk)

pkg:apk/alpine/curl@8.12.1-r0?os_name=alpine&os_version=3.21

high : CVE--2025--9086

Affected range<8.14.1-r2
Fixed version8.14.1-r2
EPSS Score0.077%
EPSS Percentile23rd percentile
Description

high : CVE--2025--5399

Affected range<8.14.1-r0
Fixed version8.14.1-r0
EPSS Score0.040%
EPSS Percentile12th percentile
Description
critical: 0 high: 1 medium: 0 low: 0 github.com/golang-jwt/jwt/v4 4.5.1 (golang)

pkg:golang/github.com/golang-jwt/jwt@4.5.1#v4

high 8.7: CVE--2025--30204 Asymmetric Resource Consumption (Amplification)

Affected range<4.5.2
Fixed version4.5.2
CVSS Score8.7
CVSS VectorCVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
EPSS Score0.064%
EPSS Percentile20th percentile
Description

Summary

Function parse.ParseUnverified currently splits (via a call to strings.Split) its argument (which is untrusted data) on periods.

As a result, in the face of a malicious request whose Authorization header consists of Bearer followed by many period characters, a call to that function incurs allocations to the tune of O(n) bytes (where n stands for the length of the function's argument), with a constant factor of about 16. Relevant weakness: CWE-405: Asymmetric Resource Consumption (Amplification)

Details

See parse.ParseUnverified

Impact

Excessive memory allocation

critical: 0 high: 1 medium: 0 low: 0 github.com/golang-jwt/jwt 3.2.2+incompatible (golang)

pkg:golang/github.com/golang-jwt/jwt@3.2.2%2Bincompatible

high 8.7: CVE--2025--30204 Asymmetric Resource Consumption (Amplification)

Affected range>=3.2.0
<=3.2.2
Fixed versionNot Fixed
CVSS Score8.7
CVSS VectorCVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
EPSS Score0.064%
EPSS Percentile20th percentile
Description

Summary

Function parse.ParseUnverified currently splits (via a call to strings.Split) its argument (which is untrusted data) on periods.

As a result, in the face of a malicious request whose Authorization header consists of Bearer followed by many period characters, a call to that function incurs allocations to the tune of O(n) bytes (where n stands for the length of the function's argument), with a constant factor of about 16. Relevant weakness: CWE-405: Asymmetric Resource Consumption (Amplification)

Details

See parse.ParseUnverified

Impact

Excessive memory allocation

critical: 0 high: 1 medium: 0 low: 0 c-ares 1.34.3-r0 (apk)

pkg:apk/alpine/c-ares@1.34.3-r0?os_name=alpine&os_version=3.21

high : CVE--2025--31498

Affected range<1.34.5-r0
Fixed version1.34.5-r0
EPSS Score0.135%
EPSS Percentile34th percentile
Description
critical: 0 high: 1 medium: 0 low: 0 golang.org/x/crypto 0.35.0 (golang)

pkg:golang/golang.org/x/crypto@0.35.0

high : CVE--2025--47913

Affected range<0.43.0
Fixed version0.43.0
EPSS Score0.018%
EPSS Percentile4th percentile
Description

SSH clients receiving SSH_AGENT_SUCCESS when expecting a typed response will panic and cause early termination of the client process.

critical: 0 high: 1 medium: 0 low: 0 golang.org/x/crypto 0.36.0 (golang)

pkg:golang/golang.org/x/crypto@0.36.0

high : CVE--2025--47913

Affected range<0.43.0
Fixed version0.43.0
EPSS Score0.018%
EPSS Percentile4th percentile
Description

SSH clients receiving SSH_AGENT_SUCCESS when expecting a typed response will panic and cause early termination of the client process.

critical: 0 high: 1 medium: 0 low: 0 openssl 3.3.3-r0 (apk)

pkg:apk/alpine/openssl@3.3.3-r0?os_name=alpine&os_version=3.21

high : CVE--2025--9230

Affected range<3.3.5-r0
Fixed version3.3.5-r0
EPSS Score0.025%
EPSS Percentile6th percentile
Description
critical: 0 high: 1 medium: 0 low: 0 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc 0.36.4 (golang)

pkg:golang/go.opentelemetry.io/contrib/instrumentation@0.36.4#google.golang.org/grpc/otelgrpc

high : CVE--2023--47108 OWASP Top Ten 2017 Category A9 - Using Components with Known Vulnerabilities

Affected range<0.46.0
Fixed version0.46.0
EPSS Score4.299%
EPSS Percentile88th percentile
Description

OpenTelemetry-Go Contrib is a collection of third-party packages for OpenTelemetry-Go. Prior to version 0.46.0, the grpc Unary Server Interceptor out of the box adds labels net.peer.sock.addr and net.peer.sock.port that have unbound cardinality. It leads to the server's potential memory exhaustion when many malicious requests are sent. An attacker can easily flood the peer address and port for requests. Version 0.46.0 contains a fix for this issue. As a workaround to stop being affected, a view removing the attributes can be used. The other possibility is to disable grpc metrics instrumentation by passing otelgrpc.WithMeterProvider option with noop.NewMeterProvider.

critical: 0 high: 1 medium: 0 low: 0 golang.org/x/oauth2 0.26.0 (golang)

pkg:golang/golang.org/x/oauth2@0.26.0

high 7.5: CVE--2025--22868 Improper Validation of Syntactic Correctness of Input

Affected range<0.27.0
Fixed version0.27.0
CVSS Score7.5
CVSS VectorCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
EPSS Score0.116%
EPSS Percentile31st percentile
Description

An attacker can pass a malicious malformed token which causes unexpected memory to be consumed during parsing.

critical: 0 high: 1 medium: 0 low: 0 golang.org/x/oauth2 0.7.0 (golang)

pkg:golang/golang.org/x/oauth2@0.7.0

high 7.5: CVE--2025--22868 Improper Validation of Syntactic Correctness of Input

Affected range<0.27.0
Fixed version0.27.0
CVSS Score7.5
CVSS VectorCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
EPSS Score0.116%
EPSS Percentile31st percentile
Description

An attacker can pass a malicious malformed token which causes unexpected memory to be consumed during parsing.

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: 1

🧹 Nitpick comments (2)
workers/main/src/index.ts (1)

29-43: Clarify whether schedule setup failures should block worker startup

Right now:

  • You always connect a client, run setupWeeklyReportSchedule, log any error in the catch, and then still proceed to create and run the worker.
  • Only connection failure before the try will abort run() (via the outer run().catch(handleRunError) path).

If the weekly financial report schedule is business‑critical, you may want to fail fast instead of silently continuing after a logged error, for example:

  try {
    const client = new Client({ connection: clientConnection });

    await setupWeeklyReportSchedule(client);
  } catch (err) {
    logger.error(
      `Failed to setup schedule: ${err instanceof Error ? err.message : String(err)}`,
    );
-  } finally {
+    // Optionally rethrow if schedule setup must succeed before worker runs
+    // throw err;
+  } finally {
    await clientConnection.close();
  }

If it’s acceptable for the worker to run even when schedule initialization fails (e.g., you’ll repair the schedule separately), then the current behavior is fine, but it’s worth confirming that this trade‑off is intentional.

workers/main/src/configs/schedules.ts (1)

3-55: Avoid circular dependency on logger and tighten schedule existence/error handling

Functionality looks correct overall (ID, cron, timezone, overlap, catchup), but there are a few structural points worth considering:

  • Circular dependency via logger: workers/main/src/index.ts imports setupWeeklyReportSchedule from this file, while this file imports logger from ../index. This works in the current CommonJS setup but is fragile (especially if you later switch to ESM or want to load this module in isolation for tests). Consider moving logger into a small shared module (e.g. ../logging) and importing it from both places, or passing a logger into setupWeeklyReportSchedule as a parameter.

  • Inner describe() catch block: The inner try/catch around scheduleHandle.describe() intentionally treats any error as “schedule doesn’t exist” and proceeds to create it. That’s reasonable, but:

    • It can mask other problems (e.g. permission issues, connectivity blips) as “just create it”.
    • It’s also what Sonar is complaining about (“Handle this exception or don't catch it at all”) since the caught error is effectively ignored.

    Two lightweight options that keep things simple but make behavior clearer:

    • At minimum, include the error message in the “Creating schedule…” log so you can distinguish “not found” from other failures.
    • Or, alternatively, simplify by dropping the describe() check and just create() unconditionally, catching the “already exists” error from create and logging that as a no‑op; this also avoids the small race between describe() and create() if multiple instances run this code.

Given your preference for keeping early‑stage code simple, I’d treat these as optional cleanups rather than blockers, but they would improve robustness and appease static analysis.

📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 622ed8a and 4e7e2a3.

📒 Files selected for processing (3)
  • workers/main/src/configs/schedules.ts (1 hunks)
  • workers/main/src/configs/temporal.ts (1 hunks)
  • workers/main/src/index.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Follow the function naming pattern: prefix? + action (A) + high context (HC) + low context? (LC), using action verbs such as get, fetch, send, create, validate, handle, calculate, and boolean prefixes is, has, should
Use descriptive, unabbreviated variable names; use singular for single values and plural for collections; ensure variable names are context-specific

Files:

  • workers/main/src/index.ts
  • workers/main/src/configs/temporal.ts
  • workers/main/src/configs/schedules.ts
workers/main/src/configs/**

📄 CodeRabbit inference engine (CLAUDE.md)

workers/main/src/configs/**: Environment validation should be implemented in workers/main/src/configs/
Use Zod schemas for environment validation

Files:

  • workers/main/src/configs/temporal.ts
  • workers/main/src/configs/schedules.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: anatolyshipitz
Repo: speedandfunction/automatization PR: 34
File: workers/main/src/workflows/financial/FinancialReportFormatter.ts:3-7
Timestamp: 2025-05-30T17:57:21.010Z
Learning: User anatolyshipitz prefers to keep code implementations simple during early development stages rather than adding comprehensive error handling and validation. They consider extensive type annotations and error handling "redundant" when focusing on core functionality and testing.
📚 Learning: 2025-07-29T15:56:21.892Z
Learnt from: CR
Repo: speedandfunction/automatization PR: 0
File: .cursor/rules/temporal-project-structure.mdc:0-0
Timestamp: 2025-07-29T15:56:21.892Z
Learning: Applies to workers/*/{workflows,activities,index.ts,README.md,types.ts} : All Temporal workers must be placed under 'workers/<worker-name>/' and include: 'workflows/' (workflow definitions), 'activities/' (activity implementations), 'index.ts' (worker entry point), 'types.ts' (optional), and 'README.md' (usage and development instructions).

Applied to files:

  • workers/main/src/index.ts
  • workers/main/src/configs/temporal.ts
  • workers/main/src/configs/schedules.ts
🧬 Code graph analysis (1)
workers/main/src/index.ts (2)
workers/main/src/configs/temporal.ts (1)
  • temporalConfig (10-12)
workers/main/src/configs/schedules.ts (1)
  • setupWeeklyReportSchedule (14-56)
🪛 GitHub Check: SonarCloud Code Analysis
workers/main/src/configs/schedules.ts

[warning] 24-27: Handle this exception or don't catch it at all.

See more on https://sonarcloud.io/project/issues?id=speedandfunction_automatization&issues=AZrpiukPMmY-99-tg61q&open=AZrpiukPMmY-99-tg61q&pullRequest=115

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Docker Security Scanning (n8n, Dockerfile.n8n, n8n-test:latest)
  • GitHub Check: Service Availability Check
🔇 Additional comments (2)
workers/main/src/index.ts (1)

1-8: Imports and shared Temporal config look consistent

The new @temporalio/client imports and reuse of temporalConfig for both client and worker connections are consistent with the rest of the file and keep the address configuration centralized.

workers/main/src/configs/schedules.ts (1)

61-66: scheduleConfig is a useful metadata export

Exporting scheduleConfig as a const object for documentation/tests is a good pattern and keeps the schedule parameters discoverable; just remember to update it alongside any future changes to the actual schedule spec.

- Removed unnecessary blank lines in the schedule configuration comments to enhance readability.
- Ensured that the documentation clearly outlines the weekly financial report schedule details.

These changes improve the clarity and presentation of the schedule configuration documentation.
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: 1

🧹 Nitpick comments (1)
workers/main/src/configs/schedules.ts (1)

18-32: Improve error handling specificity and clarify log message for schedule existence check

The idempotent describe() + create() pattern is solid. However, the current implementation catches all errors from describe() as "schedule doesn't exist," which masks real issues like connectivity or auth failures. The Temporal TypeScript SDK throws a specific ScheduleNotFoundError when a schedule doesn't exist—catch this exception specifically and let other errors propagate so misconfigurations fail fast.

The log message "Creating schedule ${SCHEDULE_ID} with error: ${errorMessage}" is also misleading; it should clarify that the schedule is being created because describe() failed, not because an error is expected during creation.

Example improvement:

  • Import ScheduleNotFoundError from @temporalio/client
  • Replace the generic catch(error) with catch(error: Error) and check if (error instanceof ScheduleNotFoundError)
  • Update the log to something like "Schedule ${SCHEDULE_ID} not found, creating it" or "Creating schedule ${SCHEDULE_ID} because describe() failed: ${errorMessage}"
📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4e7e2a3 and 95a45d0.

📒 Files selected for processing (2)
  • workers/main/src/configs/schedules.ts (1 hunks)
  • workers/main/src/configs/temporal.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • workers/main/src/configs/temporal.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Follow the function naming pattern: prefix? + action (A) + high context (HC) + low context? (LC), using action verbs such as get, fetch, send, create, validate, handle, calculate, and boolean prefixes is, has, should
Use descriptive, unabbreviated variable names; use singular for single values and plural for collections; ensure variable names are context-specific

Files:

  • workers/main/src/configs/schedules.ts
workers/main/src/configs/**

📄 CodeRabbit inference engine (CLAUDE.md)

workers/main/src/configs/**: Environment validation should be implemented in workers/main/src/configs/
Use Zod schemas for environment validation

Files:

  • workers/main/src/configs/schedules.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: anatolyshipitz
Repo: speedandfunction/automatization PR: 34
File: workers/main/src/workflows/financial/FinancialReportFormatter.ts:3-7
Timestamp: 2025-05-30T17:57:21.010Z
Learning: User anatolyshipitz prefers to keep code implementations simple during early development stages rather than adding comprehensive error handling and validation. They consider extensive type annotations and error handling "redundant" when focusing on core functionality and testing.
📚 Learning: 2025-07-29T15:56:21.892Z
Learnt from: CR
Repo: speedandfunction/automatization PR: 0
File: .cursor/rules/temporal-project-structure.mdc:0-0
Timestamp: 2025-07-29T15:56:21.892Z
Learning: Applies to workers/*/{workflows,activities,index.ts,README.md,types.ts} : All Temporal workers must be placed under 'workers/<worker-name>/' and include: 'workflows/' (workflow definitions), 'activities/' (activity implementations), 'index.ts' (worker entry point), 'types.ts' (optional), and 'README.md' (usage and development instructions).

Applied to files:

  • workers/main/src/configs/schedules.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Docker Security Scanning (n8n, Dockerfile.n8n, n8n-test:latest)
  • GitHub Check: Service Availability Check
🔇 Additional comments (1)
workers/main/src/configs/schedules.ts (1)

34-50: Schedule configuration and exported metadata look correct and consistent

The schedule definition matches the stated requirement:

  • cronExpressions: ['0 13 * * 2'] with timezone: 'America/New_York' correctly encodes “every Tuesday at 1 PM EST/EDT”.
  • overlap: 'SKIP' plus catchupWindow: '1 day' is a sensible default for this kind of reporting workflow.
  • Using weeklyFinancialReportsWorkflow and workerConfig.taskQueue keeps the schedule aligned with the worker configuration.
  • scheduleConfig reuses SCHEDULE_ID and the same cron/timezone, which reduces drift between runtime config and documentation/tests.

All of this looks good and is easy to understand/maintain.

Also applies to: 66-71

- Updated the log message in `setupWeeklyReportSchedule` to clarify the reason for creating a new schedule when it is not found.
- Enhanced the documentation in `temporal.ts` to direct users to the `scheduleConfig` object for detailed schedule configuration information.

These changes improve the clarity of error messages and documentation, aiding in better understanding and maintenance of the scheduling system.
- Moved the logger instance to a new `logger.ts` file for better organization and reusability.
- Updated import paths in `index.ts`, `index.test.ts`, and `schedules.ts` to reference the new logger module.
- Ensured that the logger is consistently used across the application, improving maintainability and clarity.

These changes streamline the logging setup and enhance code structure.
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

🧹 Nitpick comments (2)
workers/main/src/index.ts (2)

1-2: Simplify logger re-export to match Sonar suggestion

You can drop the separate import + export and re-export logger in one line, which also satisfies the Sonar warning:

-import { logger } from './logger';
-
-export { logger };
+export { logger } from './logger';

Also applies to: 6-6, 9-9, 11-11


30-47: Schedule setup flow is correct; be aware of double-logging

The best-effort schedule setup before starting the worker looks correct: errors during setupWeeklyReportSchedule are logged and don’t block worker startup, and the temporary client connection is properly closed in finally.

Note that setupWeeklyReportSchedule already logs failures and rethrows, so this catch will log the same error a second time. If you want to avoid duplicate log lines in the future, you could either:

  • Let setupWeeklyReportSchedule log and not rethrow, or
  • Let it throw and log only here.

Given the current objectives, the existing behavior is acceptable and simple.

📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 95a45d0 and 4a8ecda.

📒 Files selected for processing (5)
  • workers/main/src/configs/schedules.ts (1 hunks)
  • workers/main/src/configs/temporal.ts (1 hunks)
  • workers/main/src/index.test.ts (1 hunks)
  • workers/main/src/index.ts (2 hunks)
  • workers/main/src/logger.ts (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • workers/main/src/index.test.ts
  • workers/main/src/configs/temporal.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • workers/main/src/configs/schedules.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Follow the function naming pattern: prefix? + action (A) + high context (HC) + low context? (LC), using action verbs such as get, fetch, send, create, validate, handle, calculate, and boolean prefixes is, has, should
Use descriptive, unabbreviated variable names; use singular for single values and plural for collections; ensure variable names are context-specific

Files:

  • workers/main/src/logger.ts
  • workers/main/src/index.ts
🧠 Learnings (4)
📓 Common learnings
Learnt from: anatolyshipitz
Repo: speedandfunction/automatization PR: 34
File: workers/main/src/workflows/financial/FinancialReportFormatter.ts:3-7
Timestamp: 2025-05-30T17:57:21.010Z
Learning: User anatolyshipitz prefers to keep code implementations simple during early development stages rather than adding comprehensive error handling and validation. They consider extensive type annotations and error handling "redundant" when focusing on core functionality and testing.
📚 Learning: 2025-08-05T13:42:48.295Z
Learnt from: CR
Repo: speedandfunction/automatization PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-05T13:42:48.295Z
Learning: Applies to workers/main/tsconfig.json : TypeScript configuration should be defined in workers/main/tsconfig.json

Applied to files:

  • workers/main/src/logger.ts
📚 Learning: 2025-07-29T15:56:21.892Z
Learnt from: CR
Repo: speedandfunction/automatization PR: 0
File: .cursor/rules/temporal-project-structure.mdc:0-0
Timestamp: 2025-07-29T15:56:21.892Z
Learning: New workers must not duplicate logic already present in shared modules; place all shared code in 'workers-shared/' to maximize reuse and maintainability.

Applied to files:

  • workers/main/src/logger.ts
📚 Learning: 2025-07-29T15:56:21.892Z
Learnt from: CR
Repo: speedandfunction/automatization PR: 0
File: .cursor/rules/temporal-project-structure.mdc:0-0
Timestamp: 2025-07-29T15:56:21.892Z
Learning: Applies to workers/*/{workflows,activities,index.ts,README.md,types.ts} : All Temporal workers must be placed under 'workers/<worker-name>/' and include: 'workflows/' (workflow definitions), 'activities/' (activity implementations), 'index.ts' (worker entry point), 'types.ts' (optional), and 'README.md' (usage and development instructions).

Applied to files:

  • workers/main/src/index.ts
🧬 Code graph analysis (2)
workers/main/src/logger.ts (1)
workers/main/src/index.ts (1)
  • logger (11-11)
workers/main/src/index.ts (3)
workers/main/src/configs/temporal.ts (1)
  • temporalConfig (10-12)
workers/main/src/configs/schedules.ts (1)
  • setupWeeklyReportSchedule (14-61)
workers/main/src/logger.ts (1)
  • logger (7-7)
🪛 GitHub Check: SonarCloud Code Analysis
workers/main/src/index.ts

[warning] 11-11: Use export…from to re-export logger.

See more on https://sonarcloud.io/project/issues?id=speedandfunction_automatization&issues=AZrpq407_7Q74VH4nFJd&open=AZrpq407_7Q74VH4nFJd&pullRequest=115

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Docker Security Scanning (n8n, Dockerfile.n8n, n8n-test:latest)
  • GitHub Check: Service Availability Check
🔇 Additional comments (1)
workers/main/src/logger.ts (1)

1-7: Shared logger extraction looks good

Centralizing the DefaultLogger('ERROR') in its own module is clean and keeps production logging noise low; no issues here.

- Changed the workflowType in the setupWeeklyReportSchedule function from a direct import to a string reference for 'weeklyFinancialReportsWorkflow'.
- This adjustment improves clarity and consistency in the schedule setup process.

These changes enhance the maintainability of the scheduling configuration.
- Changed logger level from ERROR to INFO to capture important operational messages, including schedule setup, errors, and warnings.
- Introduced validation functions to check if a schedule exists and handle "not found" errors more gracefully, improving error handling in the setupWeeklyReportSchedule function.

These changes enhance logging clarity and improve the robustness of schedule management.
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: 1

🧹 Nitpick comments (2)
workers/main/src/configs/schedules.ts (2)

11-17: Predicate naming could better reflect boolean intent

validateIsScheduleNotFoundError returns a boolean and is only used as a predicate. Renaming to something like isScheduleNotFoundError would better match its usage and the naming guideline for boolean helpers, and keep call sites more readable.


53-59: Avoid duplication between schedule creation and scheduleConfig

cronExpression and timezone are defined both inline in setupWeeklyReportSchedule and again in scheduleConfig. This can drift if one is updated without the other.

You could reuse scheduleConfig in the create call, e.g.:

await client.schedule.create({
  scheduleId: scheduleConfig.scheduleId,
  spec: {
    cronExpressions: [scheduleConfig.cronExpression],
    timezone: scheduleConfig.timezone,
  },
  // ...
});

This keeps the schedule behavior and the exported config in sync with a single source of truth.

Also applies to: 85-90

📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a8ecda and 13ff085.

📒 Files selected for processing (2)
  • workers/main/src/configs/schedules.ts (1 hunks)
  • workers/main/src/logger.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • workers/main/src/logger.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Follow the function naming pattern: prefix? + action (A) + high context (HC) + low context? (LC), using action verbs such as get, fetch, send, create, validate, handle, calculate, and boolean prefixes is, has, should
Use descriptive, unabbreviated variable names; use singular for single values and plural for collections; ensure variable names are context-specific

Files:

  • workers/main/src/configs/schedules.ts
workers/main/src/configs/**

📄 CodeRabbit inference engine (CLAUDE.md)

workers/main/src/configs/**: Environment validation should be implemented in workers/main/src/configs/
Use Zod schemas for environment validation

Files:

  • workers/main/src/configs/schedules.ts
🧠 Learnings (4)
📓 Common learnings
Learnt from: anatolyshipitz
Repo: speedandfunction/automatization PR: 34
File: workers/main/src/workflows/financial/FinancialReportFormatter.ts:3-7
Timestamp: 2025-05-30T17:57:21.010Z
Learning: User anatolyshipitz prefers to keep code implementations simple during early development stages rather than adding comprehensive error handling and validation. They consider extensive type annotations and error handling "redundant" when focusing on core functionality and testing.
📚 Learning: 2025-07-29T15:56:21.892Z
Learnt from: CR
Repo: speedandfunction/automatization PR: 0
File: .cursor/rules/temporal-project-structure.mdc:0-0
Timestamp: 2025-07-29T15:56:21.892Z
Learning: Applies to workers/*/{workflows,activities,index.ts,README.md,types.ts} : All Temporal workers must be placed under 'workers/<worker-name>/' and include: 'workflows/' (workflow definitions), 'activities/' (activity implementations), 'index.ts' (worker entry point), 'types.ts' (optional), and 'README.md' (usage and development instructions).

Applied to files:

  • workers/main/src/configs/schedules.ts
📚 Learning: 2025-07-29T15:56:21.892Z
Learnt from: CR
Repo: speedandfunction/automatization PR: 0
File: .cursor/rules/temporal-project-structure.mdc:0-0
Timestamp: 2025-07-29T15:56:21.892Z
Learning: New workers must not duplicate logic already present in shared modules; place all shared code in 'workers-shared/' to maximize reuse and maintainability.

Applied to files:

  • workers/main/src/configs/schedules.ts
📚 Learning: 2025-08-05T13:42:48.295Z
Learnt from: CR
Repo: speedandfunction/automatization PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-05T13:42:48.295Z
Learning: Applies to workers/main/tsconfig.json : TypeScript configuration should be defined in workers/main/tsconfig.json

Applied to files:

  • workers/main/src/configs/schedules.ts
🧬 Code graph analysis (1)
workers/main/src/configs/schedules.ts (2)
workers/main/src/logger.ts (1)
  • logger (8-8)
workers/main/src/configs/worker.ts (1)
  • workerConfig (4-6)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Docker Security Scanning (n8n, Dockerfile.n8n, n8n-test:latest)
  • GitHub Check: Service Availability Check

- Renamed `setupWeeklyReportSchedule` to `createScheduleWithRaceProtection` to better reflect its functionality.
- Added logic to handle race conditions when creating schedules, allowing the function to gracefully handle cases where a schedule already exists.
- Updated the `setupWeeklyReportSchedule` function to utilize the new schedule creation method, maintaining its original purpose while enhancing robustness.

These changes improve the reliability of the scheduling system by preventing conflicts during schedule creation.
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 4, 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