Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 14, 2025

This PR fixes an issue where NUMBER field types could not be updated because string values from GitHub Actions inputs were being passed directly to the GraphQL API, which expects numeric values.

Problem

When updating a NUMBER field with a value like 0, the GitHub Actions input system provides the value as a string "0". The existing code passed this string directly to the GraphQL mutation, but the API expects a numeric value for NUMBER fields, causing the update to fail.

# This workflow would fail to update NUMBER fields
- name: Update field value
  uses: github/update-project-action@v3
  with:
    field: my_number_field
    value: 0  # Becomes string "0" internally

Solution

Added type conversion logic to properly handle NUMBER fields:

  1. New convertValueToFieldType() function - Converts string inputs to the appropriate type based on the field type:

    • NUMBER fields: Converts strings like "0", "42", "3.14" to numeric values
    • Other fields: Returns the original string value unchanged
  2. Updated updateField() function - Now uses converted values instead of raw string inputs for all non-single-select fields

  3. Comprehensive test coverage - Added tests for various number formats including the specific case mentioned in the issue

Testing

The fix includes tests for:

  • Converting string "0" to numeric 0 (the exact case from the issue)
  • Converting integer and float strings to numbers
  • Error handling for invalid number strings
  • Ensuring existing functionality for TEXT, DATE, and SINGLE_SELECT fields remains unchanged

All existing tests continue to pass, ensuring backward compatibility.

Fixes #171.


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

Copy link
Contributor Author

Copilot AI commented Aug 14, 2025

@benbalter 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Co-authored-by: benbalter <282759+benbalter@users.noreply.github.com>
Copilot AI changed the title [WIP] Can't update the value of a NUMBER field type Fix NUMBER field update issue by converting string values to numbers Aug 14, 2025
Copilot AI requested a review from benbalter August 14, 2025 22:32
@benbalter benbalter marked this pull request as ready for review August 14, 2025 23:04
Copilot AI review requested due to automatic review settings August 14, 2025 23:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where NUMBER field types could not be updated in GitHub Projects due to string values from GitHub Actions inputs being passed directly to the GraphQL API, which expects numeric values.

  • Added type conversion logic to convert string inputs to appropriate types based on field type
  • Updated the updateField function to use converted values for non-single-select fields
  • Added comprehensive test coverage for number field conversions and edge cases

Reviewed Changes

Copilot reviewed 2 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/update-project.ts Added convertValueToFieldType function and updated updateField to handle type conversion
test/main.test.ts Added unit tests for the new conversion function and integration tests for number field updates

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@benbalter benbalter merged commit c877a94 into main Aug 15, 2025
2 of 3 checks passed
@benbalter benbalter deleted the copilot/fix-171 branch August 15, 2025 17:55
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.

Can't update the value of a NUMBER field type

2 participants