Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix list_project_fields JSON unmarshal error for single_select fields#1490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
Copilot wants to merge2 commits intomain
base:main
Choose a base branch
Loading
fromcopilot/fix-list-project-fields-bug

Conversation

Copy link
Contributor

CopilotAI commentedNov 26, 2025
edited
Loading

Closes:#1418

list_project_fields fails when projects containsingle_select fields with options:

json: cannot unmarshal object into Go struct field ProjectV2FieldOption.options.name of type string

Root cause: go-github v79 expectsoptions.name to be*ProjectV2TextContent (object), but the GitHub API returns a plain string.

Fix: Custom types with flexible JSON unmarshaling that handles both formats:

  • FlexibleString: Custom type withUnmarshalJSON that accepts either"Backlog" or{"raw": "Backlog", "html": "Backlog"}
  • ProjectField types: Local structs usingFlexibleString for option names/descriptions
  • Raw API calls:ListProjectFields andGetProjectField now useclient.NewRequest/Do with our types instead of go-github's broken types
// FlexibleString handles both string and object formatsfunc (f*FlexibleString)UnmarshalJSON(data []byte)error {varsstringiferr:=json.Unmarshal(data,&s);err==nil {f.Raw,f.HTML=s,sreturnnil    }// Fall back to object formattypealiasFlexibleStringreturnjson.Unmarshal(data, (*alias)(f))}

Tradeoffs: Duplicates some go-github types locally. This is preferable to waiting for an upstream fix or forking the library.

Alternatives: Could have submitted a PR to go-github, but that would leave users broken until a new release. Local fix provides immediate resolution.

Original prompt

This section details on the original issue you should resolve

<issue_title>list_project_fields fails with JSON unmarshal error for single_select fields with options</issue_title>
<issue_description>## Bug Description

Thelist_project_fields tool fails when trying to retrieve project fields that includesingle_select fields with options (e.g., Status, Priority, Size fields). I found this when creating a custom agent that has been granted the ability to create/update issues and move them around a project board by changing the status.

Error Message

failed to list project fields: json: cannot unmarshal object into Go struct field ProjectV2FieldOption.options.name of type string

Steps to Reproduce

  1. Create or use a GitHub Project (v2) that has a single_select field with options (e.g., Status field with Backlog, In Progress, Done, etc.)

  2. Calllist_project_fields tool with the project details:

    owner_type: "user"owner: "<username>"project_number: <project_number>
  3. Observe the JSON unmarshal error

Expected Behavior

The tool should successfully return all project fields, including single_select fields with their options listed.

Actual Behavior

The tool fails with a JSON unmarshal error because it's trying to unmarshal the options structure incorrectly.

Root Cause

The GitHub GraphQL API returns options for single_select fields as an array of objects with this structure:

{"options": [    {"id":"aeba538c","name":"Backlog"    },    {"id":"f75ad846","name":"Ready"    }  ]}

However, the Go struct appears to be expectingoptions.name to be a simple string type instead of an object withid andname properties.

Workaround

Until this is fixed, I have been using the GitHub GraphQL API directly to retrieve field information and placing the result in the agent definition so that the agent does not need to call thelist_project_fields tool:

query {user(login:"username") {projectV2(number:4) {fields(first:20) {nodes {...onProjectV2Field {idnamedataTypedatabaseId          }...onProjectV2SingleSelectField {idnamedataTypedatabaseIdoptions {idname            }          }        }      }    }  }}

Suggested Fix

Update the Go struct definition forProjectV2FieldOption to properly handle the options structure where each option is an object containingid andname fields, rather than expecting a simple string.

Environment

  • GitHub MCP Server version: [latest as of November 2025]
  • Affected tool:list_project_fields
  • I get the same error when I test locally in VS CODE and using the Coding Agent in GitHub with the same agent definition.
    </issue_description>

Comments on the Issue (you are@copilot in this section)


✨ Let Copilot coding agentset things up for you — coding agent works faster and does higher quality work when set up for your repo.

The go-github v79 library expects `options.name` to be an object(`*ProjectV2TextContent`) but the GitHub API returns a simple string.This fix:- Creates custom types (FlexibleString, ProjectField, etc.) that can  handle both string and object formats for option names- Implements custom UnmarshalJSON for FlexibleString to handle either format- Updates ListProjectFields and GetProjectField to use raw API requests  with our custom types instead of the go-github library's types- Adds tests for both string and object name formatsCo-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>
CopilotAI changed the title[WIP] Fix JSON unmarshal error in list_project_fields for single_select fieldsFix list_project_fields JSON unmarshal error for single_select fieldsNov 26, 2025
CopilotAI requested a review fromJoannaaKLNovember 26, 2025 08:18
Copilot finished work on behalf ofJoannaaKLNovember 26, 2025 08:18
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@JoannaaKLJoannaaKLAwaiting requested review from JoannaaKL

At least 1 approving review is required to merge this pull request.

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

list_project_fields fails with JSON unmarshal error for single_select fields with options

2 participants

@JoannaaKL

[8]ページ先頭

©2009-2025 Movatter.jp