linearis icon indicating copy to clipboard operation
linearis copied to clipboard

milestones create/update: variables wrapped in { input } but mutations use flat variables (create hard-fails; update silently drops fields)

Open ryanrozich opened this issue 5 months ago • 2 comments

Summary

milestones create hard-fails and milestones update silently drops fields. Both stem from the same mistake in src/services/milestone-service.ts: the variables are passed wrapped in { input } (and { id, input }), but the ProjectMilestone GraphQL mutations declare flat variables ($projectId, $name, $description, $targetDate, $sortOrder) — not a single $input object. So the variables arrive undefined.

Contrast with project-service (createProject), where { input } is correct because the CreateProject mutation uses a single $input: ProjectCreateInput!. The milestone mutations are different (flat vars), so the same pattern was copied incorrectly.

Version: linearis 2026.4.9 (npm global).

Bug 1 — milestones create hard-fails

$ linearis milestones create "M1" --project <projectUUID> --description "x"
{ "error": "GraphQL request failed: Variable \"$projectId\" of required type \"String!\" was not provided." }

The mutation is mutation CreateProjectMilestone($projectId: String!, $name: String!, $description: String, $targetDate: TimelessDate), but createMilestone sends { input: { projectId, name, ... } }, so $projectId/$name are never bound.

Bug 2 — milestones update silently drops --description / --target-date / --sort-order

updateMilestone sends { id, input } against mutation UpdateProjectMilestone($id: String!, $name: String, $description: String, $targetDate: TimelessDate, $sortOrder: Float). $id binds (it's top-level), but $name/$description/$targetDate/$sortOrder are nested under input and never bind — so the update succeeds with no changes and no error. This is worse than Bug 1 because it's silent.

Root cause

src/services/milestone-service.ts (compiled dist/services/milestone-service.js):

// createMilestone
const result = await client.request(CreateProjectMilestoneDocument, { input });   // ❌ should be: input
// updateMilestone
const result = await client.request(UpdateProjectMilestoneDocument, { id, input }); // ❌ should be: { id, ...input }

Fix

 export async function createMilestone(client, input) {
-    const result = await client.request(CreateProjectMilestoneDocument, { input });
+    const result = await client.request(CreateProjectMilestoneDocument, input);
 export async function updateMilestone(client, id, input) {
-    const result = await client.request(UpdateProjectMilestoneDocument, { id, input });
+    const result = await client.request(UpdateProjectMilestoneDocument, { id, ...input });

Verified against the live Linear API: both create and update (with --description and --target-date) work after this change.

Suggested follow-up

A small integration test that asserts the variables object shape matches each mutation document's declared variables would catch this class of { input } vs flat-variable mismatch across all services.

ryanrozich avatar Jun 16 '26 00:06 ryanrozich

LIN-154

linear[bot] avatar Jun 16 '26 00:06 linear[bot]

Thanks for the precise diagnosis here — you were right about the variable-shape mismatch on milestone create/update. Fixed in #238, with a regression guard added in #237 so it can't drift again. Both are now on the prerelease channel (npm i -g linearis@next, currently 2026.6.0-next.5) — would love if you could verify. Planning to roll into stable soon (#231). Happy for feedback!

iamfj avatar Jul 02 '26 11:07 iamfj