Skip to content

Omit empty releaseStrategy from UpdateInstanceInput#26

Merged
coryodaniel merged 2 commits into
mainfrom
fix/update-instance-omit-release-strategy
May 15, 2026
Merged

Omit empty releaseStrategy from UpdateInstanceInput#26
coryodaniel merged 2 commits into
mainfrom
fix/update-instance-omit-release-strategy

Conversation

@coryodaniel
Copy link
Copy Markdown
Member

Summary

mdClient.Instances.Update(ctx, id, instances.UpdateInput{Version: "latest+dev"}) fails before reaching the resolver:

input:3: Argument "input" has invalid value $input.
In field "releaseStrategy": Expected type "ReleaseStrategy", found "".

The V2 schema's UpdateInstanceInput marks releaseStrategy as deprecated and nullable. Clients that followed the migration to the +dev suffix on version shouldn't have to send the field anymore. In practice they couldn't, because the generated gen.UpdateInstanceInput emitted "releaseStrategy": "" whenever a caller left it unset, and Absinthe rejects the empty string against the ReleaseStrategy enum.

So every deprecation-following caller of Instances.Update was broken — every mass instance version <id>@latest+dev invocation, every preview command's per-instance version override, etc.

Same shape as #24 (CopyInstanceInput.Message), different field; the previous fix was a schema removal but this field is still in the schema (just deprecated), so this PR uses a genqlient directive instead.

Change

One genqlient directive on the operation:

# @genqlient(for: "UpdateInstanceInput.releaseStrategy", omitempty: true, pointer: true)
mutation UpdateInstance(
  $organizationId: ID!,
  $id: ID!,
  $input: UpdateInstanceInput!
) { ... }

Regenerated zz_generated.go. The field's Go shape moves from typed string to *ReleaseStrategy with omitempty — nil pointer ⇒ field absent on the wire, matching the deprecated + nullable schema contract.

Public instances.UpdateInput already only exposes Version, so nothing in the wrapper changes — the gen-level mapping gen.UpdateInstanceInput{Version: input.Version} keeps working.

Test plan

  • go build ./...
  • go test ./... — all packages green
  • CI

Fixes #25. Unblocks massdriver-cloud/mass#236 and #238.

The V2 mutation marks `releaseStrategy` as deprecated and nullable —
callers should be able to skip it once they migrate to the `+dev`
suffix on `version`. In practice they couldn't, because the generated
gen.UpdateInstanceInput emitted `"releaseStrategy": ""` whenever a
caller left the field unset, and Absinthe rejected the empty string
against the ReleaseStrategy enum:

    input:3: Argument "input" has invalid value $input.
    In field "releaseStrategy": Expected type "ReleaseStrategy", found "".

So every deprecation-following client (the entire CLI surface that
hits `Instances.Update`) was broken until we stopped sending the
field.

Apply `# @genqlient(for: "UpdateInstanceInput.releaseStrategy",
omitempty: true, pointer: true)` to the operation. The generated
struct goes from `ReleaseStrategy ReleaseStrategy `json:"releaseStrategy"`` to
`ReleaseStrategy *ReleaseStrategy `json:"releaseStrategy,omitempty"``
— nil pointer means absent on the wire, matches the deprecated +
nullable schema contract.

Fixes #25.
@coryodaniel coryodaniel requested a review from chrisghill May 15, 2026 23:04
Comment thread massdriver/internal/gen/genqlient.graphql
@coryodaniel coryodaniel requested a review from chrisghill May 15, 2026 23:07
@coryodaniel coryodaniel merged commit 5b3fee4 into main May 15, 2026
4 checks passed
@coryodaniel coryodaniel deleted the fix/update-instance-omit-release-strategy branch May 15, 2026 23:11
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.

UpdateInstance broken when caller doesn't set deprecated releaseStrategy

2 participants