Fix field type detection bug in update_project_item_field (fixes #9)
Ready to merge
MW
1y ago+482+482+012345678901234567890123456789-27-27-01234567890123456789
Problem
The update_project_item_field function failed when updating Number and Date fields in GitHub Projects V2. The root cause was incorrect field type detection logic that relied on unreliable field ID prefixes.
Issues Found:
- Number fields (e.g., "Story Points") with ID
PVTF_lAHOAAW1i84BADGgzgy-kZswere incorrectly treated as Text fields - Date fields (e.g., "Start Date") with ID
PVTF_lAHOAAW1i84BADGgzgy-JI8were also incorrectly treated as Text fields - Both field types have IDs starting with
PVTF_, but the code assumed this prefix always indicated Text fields - This caused GraphQL mutations with wrong field value types:
- Number fields got
{"text": "64"}instead of{"number": 64.0} - Date fields got
{"text": "2025-08-11"}instead of{"date": "2025-08-11"}
- Number fields got
Solution
Replaced unreliable ID prefix guessing with actual field metadata lookup from GitHub's GraphQL API.
Key Changes:
- Enhanced GraphQL query: Added
dataTypefield toget_project_fields_detailsquery - Improved field metadata: Store
dataTypealongside existing field information - Robust type detection: Use actual field
typeanddataTypeinstead of ID prefixes:ProjectV2FieldwithdataType: "NUMBER"→{"number": float(value)}ProjectV2FieldwithdataType: "DATE"→{"date": value}ProjectV2FieldwithdataType: "TEXT"→{"text": str(value)}ProjectV2SingleSelectField→{"singleSelectOptionId": value}
Files Modified:
src/github_projects_mcp/github_client.py: Core fix implementationpyproject.toml: Added dev dependencies for testing
Test Files Added:
test_simple_bug_demo.py: Demonstrates the original bugtest_simple_fix.py: Verifies the fix works correctlyanalysis.md: Detailed root cause analysis and implementation plangithub-projects-mcp-issue.md: Bug report with reproduction steps
Testing
- ✅ Number fields now correctly generate
{"number": 64.0} - ✅ Date fields now correctly generate
{"date": "2025-08-11"} - ✅ SingleSelect fields continue to work as before
- ✅ Comprehensive error handling for invalid field values
- ✅ Backward compatibility maintained
This fix enables reliable updates of all GitHub Projects V2 field types without depending on unreliable heuristics and fixes #9