Skip to content

Type API requests by path and fix maintenance updates - #57

Open
joehoyle wants to merge 2 commits into
mainfrom
codex/cli-api-contracts
Open

joehoyle wants to merge 2 commits into
mainfrom
codex/cli-api-contracts

Conversation

@joehoyle

@joehoyle joehoyle commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Maintenance updates previously sent { contact: ... }, while Vantage requires { contacts: [{ email: ... }] }. Maintenance set --contact now reads the existing list and appends a new email, preserving current contacts and treating existing emails as a no-op. The CLI also selects response types at call sites and serializes request bodies before TypeScript can check their shape.

This change fixes maintenance updates and introduces endpoint contracts inferred from the request path and HTTP method. All CLI REST calls use the typed client; query parameters and JSON bodies are checked before serialization, responses are inferred, and the untyped transport is private. Raw responses retain typed status handling, headers and download access. Shared response types continue to come from the Vantage frontend snapshots.

Checking the backend contracts also corrects uploads imports to send path, log searches to send search, and query arrays to use PHP-compatible bracket encoding. Deploy requests omit force unless explicitly enabled, avoiding the backend interpreting the string false as truthy. Both review fixes are entirely in the CLI. Existing command names and options are preserved. OAuth retains a separate typed form request, and signed backup downloads remain binary transfers. These contracts provide static checking rather than runtime validation of server responses.

Targets main.

Validation:

  • Strict type checking, including 18 compile-time rejection checks for invalid paths, methods, queries and request bodies.
  • All 37 compiled tests pass with deprecation warnings treated as errors on Node 26.0.0, including deploy-force and contact-preservation regressions.
  • All 11 native TypeScript maintenance/deploy regressions and all 4 source-only native tests pass on Node 26.0.0; the smoke check also passes.

Base automatically changed from codex/cli-typescript to main October 13, 2026 21:41
@joehoyle
joehoyle force-pushed the codex/cli-api-contracts branch from 9f1d1c6 to 4487856 Compare October 13, 2026 21:54
@joehoyle
joehoyle requested a review from rmccue October 13, 2026 21:56

@ferschubert-hm ferschubert-hm 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 fixes requested.

Comment thread lib/commands/stack/deploy.ts Outdated

const opts = { method: 'POST' };
return vantage.fetch( url, opts ).then( resp => {
return vantage.requestRaw( `stack/applications/${stack}/deploys`, { method: 'POST', query: { stream: true, force, build: buildId || undefined } } ).then( resp => {

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.

This now sends force=false on every deploy, on the dashboard backend, force is registered without 'type' so WordPress passes the string "false" through unchanged. Suggest force: force || undefined, the same pattern as build. Otherwise all deployes will be forced.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks @ferschubert-hm fixed in 88e7083

Comment thread lib/commands/instance/index.ts Outdated
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ contact: argv.contact }),
body: { contacts: [{ email: argv.contact }] },

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.

The backend's update_data calls set_maintenance_contact_emails() with this list, so it replaces all contacts. With a single string --contact (line 158), maintenance set on an instance with several contacts silently drops all but one.
Could --contact add only / append instead of replace?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

MM i made it fetch the existing ones and add the new contact in, fixed in 88e7083

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