Skip to content

🚧 Feature/sentry.quartz (Quartz v4 Alpha version) - #5505

Open
michaelmairegger wants to merge 22 commits into
getsentry:mainfrom
michaelmairegger:feature/sentry.quartz
Open

🚧 Feature/sentry.quartz (Quartz v4 Alpha version)#5505
michaelmairegger wants to merge 22 commits into
getsentry:mainfrom
michaelmairegger:feature/sentry.quartz

Conversation

@michaelmairegger

@michaelmairegger michaelmairegger commented Aug 24, 2026

Copy link
Copy Markdown

This PR implements and showcases Quartz.Net integration for Sentry

Note: Quartz.Net v4 is still alpha, therefore we should wait until v4 is finally released.

fixes #4601

@github-actions github-actions Bot added the risk: high PR risk score: high label Aug 24, 2026
Comment thread samples/Sentry.Samples.Quartz/Program.cs Outdated
Comment thread samples/Sentry.Samples.Quartz/Program.cs
Comment thread samples/Sentry.Samples.Quartz/Program.cs
Comment thread samples/Sentry.Samples.Quartz/Sentry.Samples.Quartz.csproj
Comment thread src/Sentry.Quartz/GlobalConfigurationExtensions.cs Outdated
Comment thread src/Sentry.Quartz/GlobalConfigurationExtensions.cs Outdated
@michaelmairegger michaelmairegger changed the title Feature/sentry.quartz Feature/sentry.quartz (Quartz v4 Alpha version) Aug 24, 2026
Comment thread samples/Sentry.Samples.Quartz/Program.cs
Comment thread src/Sentry.Quartz/SentryCronJobListener.cs Outdated
Comment thread src/Sentry.Quartz/SentryCronJobMiddleware.cs Outdated
Comment thread src/Sentry.Quartz/Sentry.Quartz.csproj Outdated
@michaelmairegger

Copy link
Copy Markdown
Author

@jamescrosswell I will continue watching Quartz.Net alpha releases and adopt it until final bits of 4.0 will be released.
I will notify you when ready.

@jamescrosswell

jamescrosswell commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

@jamescrosswell I will continue watching Quartz.Net alpha releases and adopt it until final bits of 4.0 will be released. I will notify you when ready.

Fantastic, thank you @michaelmairegger !

Maybe we mark the PR as draft until then? That let's me know it doesn't yet need my attention (you can always tag me directly if you want my input on something before v4 is released).

@michaelmairegger michaelmairegger changed the title Feature/sentry.quartz (Quartz v4 Alpha version) 🚧 Feature/sentry.quartz (Quartz v4 Alpha version) Sep 1, 2026
Comment thread src/Sentry.Quartz/SentryCronJobMiddleware.cs Outdated
Comment thread src/Sentry.Quartz/SentryCronJobMiddleware.cs Outdated
Comment thread src/Sentry.Quartz/GlobalConfigurationExtensions.cs
Comment thread src/Sentry.Quartz/GlobalConfigurationExtensions.cs Outdated
Comment thread src/Sentry.Quartz/SentryMetricsMiddleware.cs Outdated
Comment thread src/Sentry.Quartz/GlobalConfigurationExtensions.cs
Comment thread src/Sentry.Quartz/SentryCronJobMiddleware.cs Outdated
Comment thread src/Sentry.Quartz/Sentry.Quartz.csproj Outdated
Comment on lines +104 to +108
string[] normalized = cronExpression.CronExpressionString
.Replace("?", "*", StringComparison.OrdinalIgnoreCase)
.Split(' ', StringSplitOptions.RemoveEmptyEntries);

options.Interval(string.Join(" ", normalized[1..6]));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The code incorrectly slices a normalized cron expression using normalized[1..6], which omits the 'minutes' field and passes a malformed cron string to Sentry, causing monitor creation to fail.
Severity: HIGH

Suggested Fix

Change the array slice from normalized[1..6] to normalized[0..5]. This will correctly extract the first five fields (minute, hour, day, month, weekday) to form a valid 5-field Unix cron expression as expected by Sentry.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/Sentry.Quartz/SentryCronJobMiddleware.cs#L104-L108

Potential issue: In the `UpsertCronMonitor` method, the code attempts to convert a
Quartz cron expression to a 5-field Unix format for Sentry. It correctly parses the
expression, resulting in a 6-field string (including seconds). However, it then uses an
incorrect array slice `normalized[1..6]` to extract the fields. This slice omits the
'minutes' field (at index 0) and creates a malformed 5-field string. This malformed
string is passed to `SentryMonitorOptions.Interval()`, which will cause a validation
failure and an `ArgumentException`. The exception is caught and logged, but it results
in the cron monitor failing to be created, silently breaking the feature.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 59fdcd8. Configure here.

Comment thread src/Sentry.Quartz/SentryCronJobMiddleware.cs
Comment thread src/Sentry.Quartz/SentryCronJobMiddleware.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Quartz.NET like Sentry.Hangfire

2 participants