@@ -861,6 +861,26 @@ func toNewProjectType(projType string) string {
861861}
862862}
863863
864+ // validateAndConvertToInt64 ensures the value is a number and converts it to int64.
865+ func validateAndConvertToInt64 (value any ) (int64 ,error ) {
866+ switch v := value .(type ) {
867+ case float64 :
868+ // Validate that the float64 can be safely converted to int64
869+ intVal := int64 (v )
870+ if float64 (intVal )!= v {
871+ return 0 ,fmt .Errorf ("value must be a valid integer (got %v)" ,v )
872+ }
873+ return intVal ,nil
874+ case int64 :
875+ return v ,nil
876+ case int :
877+ return int64 (v ),nil
878+ default :
879+ return 0 ,fmt .Errorf ("value must be a number (got %T)" ,v )
880+ }
881+ }
882+
883+ // buildUpdateProjectItem constructs UpdateProjectItemOptions from the input map.
864884func buildUpdateProjectItem (input map [string ]any ) (* github.UpdateProjectItemOptions ,error ) {
865885if input == nil {
866886return nil ,fmt .Errorf ("updated_field must be an object" )
@@ -871,18 +891,19 @@ func buildUpdateProjectItem(input map[string]any) (*github.UpdateProjectItemOpti
871891return nil ,fmt .Errorf ("updated_field.id is required" )
872892}
873893
874- idFieldAsFloat64 , ok := idField .( float64 ) // JSON numbers are float64
875- if ! ok {
876- return nil ,fmt .Errorf ("updated_field.id must be a number" )
894+ fieldID , err := validateAndConvertToInt64 ( idField )
895+ if err != nil {
896+ return nil ,fmt .Errorf ("updated_field.id: %w" , err )
877897}
878898
879899valueField ,ok := input ["value" ]
880900if ! ok {
881901return nil ,fmt .Errorf ("updated_field.value is required" )
882902}
903+
883904payload := & github.UpdateProjectItemOptions {
884905Fields : []* github.UpdateProjectV2Field {{
885- ID :int64 ( idFieldAsFloat64 ) ,
906+ ID :fieldID ,
886907Value :valueField ,
887908}},
888909}