Skip to content

Feat: add AiEventsOnly and ApiKeyIds to subscription filters - #502

Merged
gb-8 merged 3 commits into
mainfrom
feat/subscription-ai-filters
Nov 17, 2026
Merged

gb-8 merged 3 commits into
mainfrom
feat/subscription-ai-filters

Conversation

@gb-8

@gb-8 gb-8 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Octopus Server now has two more subscription filters: AI events only and API keys (OctopusDeploy#50233). This adds them to EventNotificationSubscriptionFilter, so the Terraform provider can manage them (LEV-2325).

Changes

  • ApiKeyIds []string: the IDs of the API keys whose events the subscription is limited to.
  • AiEventsOnly *bool: limits the subscription to events by AI agents.

Leaving a filter unset keeps it

If an update sends either field as null or leaves it out, the server keeps its current value. That stops a client that doesn't know about a filter from clearing it by mistake. The JSON tags are set up so that:

  • A nil ApiKeyIds is sent as null (keep), and an empty slice is sent as [] (clear).
  • A nil AiEventsOnly is left out of the request (keep).

NewSubscription leaves both nil, so code that builds a subscription and saves it won't clear either filter.

When a subscription is created, an unset ApiKeyIds means no API key filter, and an unset AiEventsOnly means false.

Older servers ignore both fields.

Tests

Three JSON tests cover reading the fields, leaving them unset, and clearing the API keys with an empty slice. Each fails if its JSON tag is wrong.

Merging

OctopusDeploy#50233 is merged, and is in server builds from 2026.4.12560 onwards. It will be in the 2026.4 release. This is safe to merge and release before that, since older servers ignore both fields.

The Terraform provider change that uses this is OctopusDeploy/terraform-provider-octopusdeploy#324.

🤖 Generated with Claude Code

Leaving either field unset keeps the subscription's current value on update. An empty ApiKeyIds slice clears the API key filter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gb-8 gb-8 changed the title feat: add AiEventsOnly and ApiKeyIds to subscription filters Feat: add AiEventsOnly and ApiKeyIds to subscription filters Nov 17, 2026

@liam-mackie liam-mackie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor nit, but the code is fine :shipit:

Comment thread pkg/subscriptions/subscription.go Outdated
Tenants []string `json:"Tenants"`
Users []string `json:"Users"`
// ApiKeyIds limits the subscription to events raised with these API keys. Leave it nil to keep the
// subscription's current API keys when updating it; an empty slice clears them. Older servers ignore it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Older servers ignore it

Nit: It would be nice if this comment was less verbose and stated the server version(s) this is supported from.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@gb-8
gb-8 enabled auto-merge (squash) November 17, 2026 06:19
@gb-8
gb-8 merged commit 143654f into main Nov 17, 2026
6 checks passed
@gb-8
gb-8 deleted the feat/subscription-ai-filters branch November 17, 2026 06:24
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