Skip to content

fix: look up project field by node ID in setFieldValue - #39

Merged
kunwarVivek merged 1 commit into
kunwarVivek:mainfrom
fayez-nazzal:fix/set-field-value-field-lookup
Oct 20, 2026
Merged

kunwarVivek merged 1 commit into
kunwarVivek:mainfrom
fayez-nazzal:fix/set-field-value-field-lookup

Conversation

@fayez-nazzal

Copy link
Copy Markdown
Contributor

Summary

set_field_value cannot update any field: the lookup query uses ProjectV2.field(id:), but that field only accepts name. GitHub rejects the query, so moving a board item between Status columns (or setting any text/number/date/iteration field) always fails. assignItemsToIteration goes through the same path.

 setFieldValue
-  query($projectId, $fieldId) { node(id: $projectId) { ... on ProjectV2 { field(id: $fieldId) { ...fragments } } } }
+  query($fieldId)             { node(id: $fieldId) { ...fragments } }
   if no field id in response -> ResourceNotFoundError   # {} when the ID is not a project field
   makeStrategy(dataType, options) -> updateProjectV2ItemFieldValue   # unchanged

The existing unit tests mocked the invalid { node: { field } } response shape, which is why they passed. The mocks now use the real shape, and there are two new tests:

  • the lookup query uses node(id: $fieldId), not field(id:, and is sent only { fieldId }
  • an ID that belongs to a node other than a project field (GitHub returns {}) throws ResourceNotFoundError without attempting the mutation

Evidence

  • Before (v2.3.1, live GitHub, single-select Status field on an org project):

    manage_project set_field_value { value: "In progress" }
    -> GitHub API error: Field 'field' is missing required arguments: name
                         Field 'field' doesn't accept argument 'id'
    

    New tests run against the old source: 6 failed (5 existing set cases with corrected mocks + the query regression test).

    After:

    manage_project set_field_value { value: "In progress" }
    -> {"success":true,"message":"Field Status updated successfully"}
    gh api graphql ... fieldValueByName(name:"Status")  -> "In progress"
    

    Ran from this branch's npm run build output against the live project. A bogus server path was used as a control to confirm the branch build, not an installed copy, served the call.

  • npx vitest run src/__tests__/unit/services/FieldValueService.test.ts: 16 passed.

  • npx vitest run (full suite, after npm run build): 0 failed, 3063 passed vs 3061 on main (+2 new tests).

  • npm run build: passes.

  • npx biome check on the two changed files: 3 findings, the same 3 as on main (import order, an existing any). None are on changed lines, so I left them alone.

  • Not run: GitNexus impact / detect-changes from AGENTS.md (needs the GitNexus CLI, which I don't have set up as an outside contributor). I checked callers by text search instead: ProjectManagementService.setFieldValue and IterationService.assignItemsToIteration.

Merge Danger

Door: two-way

One query in one method; revert is trivial. The response contract of setFieldValue is unchanged.

Blast Radius: narrow

Only setFieldValue and its two callers. They were failing on every call, so nothing that works today can regress. Note: assignItemsToIteration gets its field ID from listProjectFields, which returns [] in my testing (findById does not load fields). That is a separate bug not fixed here, so iteration assignment may still fail upstream of this change.

🤖 Generated with Claude Code

setFieldValue resolved the field with ProjectV2.field(id:), but that
field only accepts `name`, so GitHub rejected every call:

  Field 'field' is missing required arguments: name
  Field 'field' doesn't accept argument 'id'

This broke manage_project set_field_value (e.g. moving a board item
between Status columns) and assignItemsToIteration, which goes through
the same path. Query the field with node(id: $fieldId) instead.

The unit tests mocked the invalid response shape, so they passed.
Reshape the mocks to the real one and add a regression test on the
lookup query plus a non-field-node case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kunwarVivek
kunwarVivek marked this pull request as ready for review October 20, 2026 16:01
@kunwarVivek
kunwarVivek merged commit c1401c9 into kunwarVivek:main Oct 20, 2026
0 of 4 checks passed
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