Migrate webhook commands to SDK#159
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/commands/webhook.go">
<violation number="1" location="internal/commands/webhook.go:59">
P2: `webhook list --all --page N` no longer honors the page flag, causing a behavior regression in pagination start point.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Review carefully before merging. Consider a major version bump. |
Replaces the legacy HTTP client (getClient()) with the typed WebhooksService for show/create/update/delete/reactivate. The list command uses the typed service for the no-flag case, falling back to ac.Get / ac.GetAll for --page and --all (the SDK's Webhooks().List doesn't accept a path). Behavior, flags, and CLI surface are unchanged. Unit tests updated to the SetTestModeWithSDK pattern; assertions now match the SDK's request shape (no `webhook` body wrapper) and URL paths (no .json suffix on get/update/delete).
`webhook list --all --page N` previously dropped the page param when --all was set, causing GetAll to start at page 1 instead of page N. The legacy client's GetWithPagination preserved the start page when paging through all results; the migration regressed this. Fixed by appending the page param to the path before invoking GetAll. Added a unit test to lock in the behavior.
The webhook migration removed the only call site (Webhooks().Create returns the full struct directly, no Location follow). Drop the dead helper to satisfy the unused-code lint check.
e83f22c to
52ac9f5
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
webhook show|create|update|delete|reactivatefrom the legacy HTTP client (getClient()) to the typedWebhooksServiceon the SDK account client.webhook listuses the typed service for the no-flag case and falls back toac.Get/ac.GetAllfor--pageand--all, since the SDK'sWebhooks().Listdoesn't accept a path. (webhook deliverieswas already on the SDK and is untouched.)SURFACE.txtdoesn't change. The e2e CRUD test inwebhook_test.gocontinues to drive the same UX.Notes
SetTestModeWithSDKhttptest-backed pattern.{"webhook": {...}}wrapper. URL assertions forget/update/deletedrop the.jsonsuffix to match the SDK paths (Rails accepts both forms).Createno longer needs a Location follow-up —WebhooksService.Createreturns the fullWebhookdirectly.Summary by cubic
Migrates webhook CLI commands from the legacy HTTP client to the typed SDK for better type safety with the same CLI behavior. Also fixes list paging when using
--allwith--page.Refactors
WebhooksServiceforshow,create,update,delete, andreactivate.list: usesWebhooks().Listby default; falls back toac.Get/ac.GetAllfor--page/--all."webhook"body wrapper; dropped.jsonpaths;Createreturns fullWebhook(no Location follow-up); removed unusedprintSuccessWithLocation.SetTestModeWithSDK; assertions match new paths/payloads; errors viaconvertSDKError.Bug Fixes
webhook list --all --page Nnow starts from page N when fetching all results; added a unit test to lock this in.Written for commit e83f22c. Summary will update on new commits. Review in cubic