Skip to content

feat: pause/resume event streams#442

Merged
alnr merged 3 commits into
masterfrom
alnr/pause-event-streams
Jun 15, 2026
Merged

feat: pause/resume event streams#442
alnr merged 3 commits into
masterfrom
alnr/pause-event-streams

Conversation

@alnr

@alnr alnr commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Docs: ory/docs#2626

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added pause and resume commands to update event stream status.
    • Added --status flag support for creating and updating event streams (with validation for allowed values).
    • Updated the event stream table output to include a STATUS column.
  • Bug Fixes

    • Empty --status values are normalized to preserve default/server behavior.
  • Tests

    • Added test coverage for status validation and request body mapping.
  • Chores

    • Updated the client library version.

@alnr alnr requested a review from shaunnkhan June 15, 2026 13:21
@alnr alnr self-assigned this Jun 15, 2026
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@alnr, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 33 minutes and 19 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3c82521a-a670-4b68-9c30-5b513ccbc60b

📥 Commits

Reviewing files that changed from the base of the PR and between 96fa216 and 3d39795.

📒 Files selected for processing (1)
  • cmd/cloudx/eventstreams/flags.go
📝 Walkthrough

Walkthrough

Adds pause and resume CLI commands for event streams. Introduces StatusActive/StatusPaused constants, status validation and normalization in streamConfig.Validate(), a toSetBody() helper, a STATUS output column, new pause/resume Cobra subcommands for event streams, top-level pause/resume commands wired into the root, and bumps client-go to v1.22.51.

Changes

Pause/Resume Event Stream Feature

Layer / File(s) Summary
Status constants, validation, toSetBody helper, and output column
cmd/cloudx/eventstreams/flags.go, cmd/cloudx/eventstreams/output.go, cmd/cloudx/eventstreams/flags_test.go
Adds StatusActive/StatusPaused constants; streamConfig.Validate() normalizes empty status to nil and rejects unknown values; toSetBody() constructs SetEventStreamBody including Status and optional Type pointer; registers the --status flag; adds STATUS column to table header and row output; tests cover all validation paths and body mapping.
Pause/resume event stream subcommands and update refactor
cmd/cloudx/eventstreams/status.go, cmd/cloudx/eventstreams/update.go
Adds NewPauseEventStreamCmd and NewResumeEventStreamCmd delegating to newSetStatusCmd, which resolves project context, calls UpdateEventStream with SetEventStreamBody{Status: &status}, handles errors, and renders the updated stream. NewUpdateEventStreamCmd is refactored to use c.toSetBody() and gains workspace flag registration.
Top-level pause/resume commands and root wiring
cmd/cloudx/pause.go, cmd/cloudx/resume.go, cmd/root.go, go.mod
Adds NewPauseCmd and NewResumeCmd as top-level cloudx commands, each mounting the event stream subcommand and registering persistent flags; both are inserted into NewRootCmd's command list. Bumps client-go from v1.22.41 to v1.22.51.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • zepatrik
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is largely incomplete; it only provides a documentation link without addressing required template sections like motivation, related issues, design documents, or the included checklist items. Complete the PR description by filling out the template sections, especially the 'Related Issue or Design Document' section to reference design documentation for this new feature.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding pause/resume functionality for event streams.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch alnr/pause-event-streams

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
cmd/cloudx/eventstreams/flags.go (1)

95-95: ⚡ Quick win

Clarify the status flag default behavior in the help text.

The help text states "Defaults to %q." (active), but the actual default is an empty string that gets normalized to nil in Validate(), allowing the server to apply its own default. The help text should reflect that omitting --status defers to the server default rather than implying the CLI defaults to "active".

📝 Suggested help text revision
-	c.Status = f.String("status", "", fmt.Sprintf("The status of the event stream. Supported values are %q and %q. Defaults to %q.", StatusActive, StatusPaused, StatusActive))
+	c.Status = f.String("status", "", fmt.Sprintf("The status of the event stream. Supported values are %q and %q. If not provided, the server default applies.", StatusActive, StatusPaused))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/cloudx/eventstreams/flags.go` at line 95, The help text for the
`c.Status` flag definition using `f.String("status", ...)` currently states
"Defaults to %q." with StatusActive as the value, which misleadingly suggests
the CLI defaults to active. However, the actual behavior is that the default
value is an empty string which normalizes to nil in the Validate() method,
allowing the server to apply its own default. Update the help text format string
to clarify that when `--status` is omitted, the server default is used, rather
than implying the CLI defaults to active. Remove or revise the "Defaults to %q."
portion to accurately reflect that the flag is optional and server-determined
when not provided.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cmd/cloudx/eventstreams/status.go`:
- Around line 38-40: The error handling for ProjectID() is inconsistent across
the codebase: the current code wraps the error with cmdx.PrintOpenAPIError, but
other similar usages return the error directly without wrapping. Since
ProjectID() returns a simple error (ErrProjectNotSet), not an OpenAPI error,
remove the cmdx.PrintOpenAPIError wrapper and return the error from ProjectID()
directly to match the simpler and more consistent pattern used elsewhere.

---

Nitpick comments:
In `@cmd/cloudx/eventstreams/flags.go`:
- Line 95: The help text for the `c.Status` flag definition using
`f.String("status", ...)` currently states "Defaults to %q." with StatusActive
as the value, which misleadingly suggests the CLI defaults to active. However,
the actual behavior is that the default value is an empty string which
normalizes to nil in the Validate() method, allowing the server to apply its own
default. Update the help text format string to clarify that when `--status` is
omitted, the server default is used, rather than implying the CLI defaults to
active. Remove or revise the "Defaults to %q." portion to accurately reflect
that the flag is optional and server-determined when not provided.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fc519111-260b-4393-bbc0-d123644fe5ab

📥 Commits

Reviewing files that changed from the base of the PR and between a0c7075 and f5ad75b.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (9)
  • cmd/cloudx/eventstreams/flags.go
  • cmd/cloudx/eventstreams/flags_test.go
  • cmd/cloudx/eventstreams/output.go
  • cmd/cloudx/eventstreams/status.go
  • cmd/cloudx/eventstreams/update.go
  • cmd/cloudx/pause.go
  • cmd/cloudx/resume.go
  • cmd/root.go
  • go.mod

Comment thread cmd/cloudx/eventstreams/status.go Outdated
ProjectID() returns a plain ErrProjectNotSet, not an OpenAPI error, so
wrapping it with cmdx.PrintOpenAPIError was a no-op and semantically
misleading. Match the pattern used in create.go and update.go.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@alnr

alnr commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

The --status help text said it defaults to "active", which is accurate
for create but misleading for update: omitting --status does NOT reset a
paused stream to active. The behavior is already a partial update (an
unset status is normalized to nil and omitted from the request), so only
the wording needed fixing. Reword to state that an unset status keeps an
existing stream's current status.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@alnr alnr merged commit 52eb734 into master Jun 15, 2026
23 of 24 checks passed
@alnr alnr deleted the alnr/pause-event-streams branch June 15, 2026 19:20
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