Skip to content

fix: validate simulator notification rules#123

Merged
goanpeca merged 2 commits into
mainfrom
fix/issue-17-notification-rule-validation
Jul 13, 2026
Merged

fix: validate simulator notification rules#123
goanpeca merged 2 commits into
mainfrom
fix/issue-17-notification-rule-validation

Conversation

@goanpeca

@goanpeca goanpeca commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary:

  • Add simulator validation for bucket notification rule names, event types, isEnabled booleans, maxEventsPerBatch positive integers, webhook targets, HTTPS URLs, and unsupported fields.
  • Reject invalid rules before storing them in b2_set_bucket_notification_rules.
  • Narrow EventNotificationRule.targetConfiguration.targetType to 'webhook' and add optional maxEventsPerBatch typing.
  • Update notification rule regression coverage and stale targetType docs.

Linked issue:

Tests run:

  • pnpm test src/simulator/validation.test.ts src/simulator/fidelity.test.ts src/client.test.ts
  • pnpm run typecheck
  • pnpm run lint
  • pnpm run lint:docs

Follow-up notes:

  • None.

Copilot AI review requested due to automatic review settings July 8, 2026 13:08
@goanpeca goanpeca added this to the v0.3.0 milestone Jul 8, 2026
@goanpeca goanpeca added bug Something isn't working area: simulator Area: simulator priority: medium Medium severity labels Jul 8, 2026
@goanpeca goanpeca self-assigned this Jul 8, 2026

Copilot AI 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.

Pull request overview

This PR improves the simulator’s fidelity to the real B2 API by validating b2_set_bucket_notification_rules inputs (per Issue #17) so invalid notification rules are rejected before being stored/used, and updates related regression coverage and docs.

Changes:

  • Added validateNotificationRules() in the simulator validation layer (names, event types, webhook target type, https URL, and unknown-field rejection).
  • Wired the new validator into B2Simulator.setBucketNotificationRules so invalid rules return 400 instead of being stored.
  • Added/updated unit + fidelity tests and corrected targetType documentation to reflect 'webhook'.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/types/notifications.ts Updates notification rule docs/examples to use targetType: 'webhook'.
src/simulator/validation.ts Adds validateNotificationRules() and supporting helpers/constants.
src/simulator/validation.test.ts Adds unit tests for notification rule validation.
src/simulator/index.ts Enforces notification rule validation in setBucketNotificationRules.
src/simulator/fidelity.test.ts Adds simulator fidelity regression tests for invalid notification rules and updates existing expectations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/simulator/validation.ts
Comment thread src/types/notifications.ts
Copilot AI review requested due to automatic review settings July 8, 2026 16:08
@goanpeca goanpeca force-pushed the fix/issue-17-notification-rule-validation branch from 842293f to 8dd03b5 Compare July 8, 2026 16:08

Copilot AI 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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 8, 2026 19:43
@goanpeca goanpeca force-pushed the fix/issue-17-notification-rule-validation branch from 8dd03b5 to f323275 Compare July 8, 2026 19:43

Copilot AI 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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread src/simulator/validation.ts
Comment thread src/simulator/validation.ts
Comment thread src/types/notifications.ts Outdated
Copilot AI review requested due to automatic review settings July 13, 2026 14:59
@goanpeca goanpeca force-pushed the fix/issue-17-notification-rule-validation branch from f323275 to a508f0d Compare July 13, 2026 14:59

Copilot AI 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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 13, 2026 15:05

Copilot AI 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.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@goanpeca goanpeca marked this pull request as ready for review July 13, 2026 15:11
@goanpeca goanpeca merged commit 65869a1 into main Jul 13, 2026
29 checks passed
@goanpeca goanpeca deleted the fix/issue-17-notification-rule-validation branch July 13, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: simulator Area: simulator bug Something isn't working priority: medium Medium severity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

simulator: set_bucket_notification_rules performs no validation

2 participants