Skip to content

feat(cmd)!: Z-Send commands use the CLI login token; remove ai-hub - #286

Merged
pan93412 merged 2 commits into
mainfrom
feat/zsend-cli-token-remove-ai-hub
Oct 22, 2026
Merged

pan93412 merged 2 commits into
mainfrom
feat/zsend-cli-token-remove-ai-hub

Conversation

@pan93412

@pan93412 pan93412 commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Summary

1. Z-Send REST commands fall back to the CLI login token

email send, email scheduled list|get|cancel and email batch list|get previously required --api-key or ZSEND_API_KEY, and rejected any value without the zs_ prefix. A logged-in user got Z-Send API key is required, and passing the login token got invalid API key format: must start with zs_.

The Z-Send REST API accepts the CLI login token (verified 2026-10-22: GET /api/v1/zsend/emails/scheduled with Authorization: Bearer <CLI login token> → 200 {"scheduled_emails": null, "total_count": 0}).

Credential resolution now lives in Factory.ResolveZSendAPIKey (internal/cmdutil/zsend.go):

  1. --api-key
  2. ZSEND_API_KEY
  3. the logged-in CLI token

The zs_ prefix is still validated for explicitly supplied keys (1 and 2) only. --api-key help and the email send long help describe the fallback. Table tests cover precedence, prefix validation and the no-credential error.

2. Remove the ai-hub command group (breaking)

The production GraphQL API no longer has aihubTenant, updateAIHubAutoRechargeSettings or any AI Hub query/mutation except aihubRefundStatement; zeabur ai-hub status and zeabur ai-hub keys list return HTTP 422. This removes internal/cmd/ai-hub, pkg/api/aihub.go, the AIHubAPI interface, pkg/model/aihub.go and the registration in root.go. README, docs and CLAUDE.md had no AI Hub references.

⚠️ Breaking change

zeabur ai-hub and all its subcommands are removed (they already fail against production). The commit is marked feat(cmd)!: with a BREAKING CHANGE: footer. Releases are tag-driven via GoReleaser (last: v0.23.0); since the CLI is pre-1.0, suggest releasing this as v0.24.0 rather than a patch.

Testing

On a Linux machine with Go 1.27.1:

  • go build ./..., go vet on touched packages, go test ./internal/... ./pkg/...: all pass.
  • E2E with a logged-in CLI and ZSEND_API_KEY unset (read-only calls only):
    • zeabur email scheduled list → empty table, exit 0 (was Z-Send API key is required)
    • zeabur email scheduled list --json → []
    • zeabur email batch list → empty table
    • zeabur email scheduled list --api-key not_a_zs_key → invalid API key format: must start with zs_
    • zeabur ai-hub status → unknown command "ai-hub"; zeabur --help no longer lists it
    • email scheduled list --help shows the new --api-key description

Refs: ZEA-10524

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

pan93412 and others added 2 commits October 22, 2026 06:28
…mands

`email send`, `email scheduled list|get|cancel` and `email batch list|get`
required --api-key or ZSEND_API_KEY and rejected anything without the zs_
prefix, so a logged-in user could not use them at all. The Z-Send REST API
also accepts the CLI login token.

Resolve the credential in one place (Factory.ResolveZSendAPIKey): the
--api-key flag, then ZSEND_API_KEY, then the logged-in CLI token. The zs_
prefix check now applies only to explicitly supplied keys.

Refs: ZEA-10524

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The production GraphQL API no longer serves AI Hub (aihubTenant,
updateAIHubAutoRechargeSettings and every other AI Hub query or mutation
except aihubRefundStatement), so `zeabur ai-hub status` and
`zeabur ai-hub keys list` fail with HTTP 422.

Remove the command group, its API client and models.

BREAKING CHANGE: `zeabur ai-hub` and all of its subcommands are removed.

Refs: ZEA-10524

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Oct 22, 2026

Copy link
Copy Markdown

ZEA-10524

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T06:29:54.219844Z 900582c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

LGTM.

Verified independently: production schema introspection shows only aihubRefundStatement left under Query and no AI Hub mutations, so removing the command group matches reality. GetTokenString is on the Config interface, all six former zs_ prefix checks are consolidated into ResolveZSendAPIKey, and nothing else in the repo still hard-codes the prefix. CI is green.

Agree with shipping as v0.24.0 given the feat! footer.

@pan93412
pan93412 merged commit c32c927 into main Oct 22, 2026
4 checks passed
@pan93412
pan93412 deleted the feat/zsend-cli-token-remove-ai-hub branch October 22, 2026 06:34
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