ChangeCompositeName returning Argument Null Exception even though neither the caller nor GetNameOfComposite are null

I’ve been working with the Input System rebinding features. One thing I’m trying to implement is the ability to switch between “Simple” and “Combo” ways of activating a signature attack (either a dedicated button, or a button + the main attack button, respectively). This function, UpdateSignatureActivation, is invoked in one of my rebind button’s Stop Events.

public void UpdateSignatureActivation()
{
    if (inputActions != null)
    {
        string controlSchemeName = GetControlSchemeName();

        InputAction mainAttack = inputActions.Player.MainAttack;
        InputAction signatureAttack = inputActions.Player.SignatureAttack;

        RebindActionUI attackButton = null;
        RebindActionUI signatureButton = null;

        foreach (RebindActionUI button in buttons)
        {
            if (button.actionReference.action.id == mainAttack.id)
                attackButton = button;
            else if (button.actionReference.action.id == signatureAttack.id)
                    signatureButton = button;
        }

        if (signatureButton != null)
        {
            InputAction sigAction = signatureButton.actionReference.action;
            int startIndex = sigAction.GetBindingIndex(InputBinding.MaskByGroup(controlSchemeName));

            if (settings.GetSignatureActivationMode() == ControlPresetSettings.SignatureActivation.Simple)
            {
                if (sigAction.bindings[startIndex].effectivePath != "") // There's a "true" composite here
                {
                    string originalModifierPath = sigAction.bindings[startIndex + 1].effectivePath;

                    Debug.Log(sigAction.bindings[startIndex - 1].GetNameOfComposite());

                    sigAction.ChangeCompositeBinding(sigAction.bindings[startIndex - 1].GetNameOfComposite())
                             .WithGroup(controlSchemeName)
                             .InsertPartBinding("Modifier", "")
                             .InsertPartBinding("Button", originalModifierPath);

                    sigAction.RemoveBindingOverride(InputBinding.MaskByGroup(controlSchemeName));

                    sigAction.ChangeCompositeBinding("OneModifier")
                             .WithGroup(controlSchemeName)
                             .Erase();

                    startIndex = sigAction.GetBindingIndex(controlSchemeName);
                }
            }
        }
        // Code that is never reached due to error, but needs separately debugging
    }
}

The problem is, at Line 35, I get the following error message:

ArgumentNullException: Value cannot be null.
Parameter name: actionNameOrId

The stack trace message tells me the error is on this line. However, I know sigAction is not null because the Debug statement before it prints out “OneModifier” (even though the corresponding composite is called “Hold + Button” in the Editor), and that means the argument isn’t null either. Entering “Hold + Button” in the argument gets me the same error. Can anyone tell me what the issue is? Thank you.

Ok, so the error was coming from the InsertPartBinding extension, which does not like empty strings for path names. However, I changed that line to this:

sigAction.ChangeCompositeBinding(sigAction.bindings[startIndex - 1].GetNameOfComposite())
         .WithGroup(controlSchemeName)
         .NextPartBinding("Modifier").Erase();

sigAction.ChangeCompositeBinding(sigAction.bindings[startIndex - 1].GetNameOfComposite())
         .WithGroup(controlSchemeName)
         .NextPartBinding("Binding").Erase();

sigAction.ChangeCompositeBinding(sigAction.bindings[startIndex - 1].GetNameOfComposite())
         .WithGroup(controlSchemeName)
         .InsertPartBinding("Binding", originalModifierPath);

The full backtrace error message:

ArgumentNullException: Value cannot be null.
Parameter name: actionNameOrId
UnityEngine.InputSystem.InputActionMap.FindAction (System.String actionNameOrId, System.Boolean throwIfNotFound) (at Library/PackageCache/com.unity.inputsystem@1.5.1/InputSystem/Actions/InputActionMap.cs:453)
UnityEngine.InputSystem.InputActionMap.SetUpPerActionControlAndBindingArrays () (at Library/PackageCache/com.unity.inputsystem@1.5.1/InputSystem/Actions/InputActionMap.cs:1003)
UnityEngine.InputSystem.InputActionMap.GetBindingsForSingleAction (UnityEngine.InputSystem.InputAction action) (at Library/PackageCache/com.unity.inputsystem@1.5.1/InputSystem/Actions/InputActionMap.cs:895)
UnityEngine.InputSystem.InputAction.get_bindings () (at Library/PackageCache/com.unity.inputsystem@1.5.1/InputSystem/Actions/InputAction.cs:410)
UnityEngine.InputSystem.Samples.RebindUI.RebindActionUI.UpdateBindingDisplay () (at Assets/Samples/Input System/1.5.1/Rebinding UI/RebindActionUI.cs:213)
UnityEngine.InputSystem.Samples.RebindUI.RebindActionUI.OnActionChange (System.Object obj, UnityEngine.InputSystem.InputActionChange change) (at Assets/Samples/Input System/1.5.1/Rebinding UI/RebindActionUI.cs:537)
UnityEngine.InputSystem.Utilities.DelegateHelpers.InvokeCallbacksSafe[TValue1,TValue2] (UnityEngine.InputSystem.Utilities.CallbackArray`1[System.Action`2[TValue1,TValue2]]& callbacks, TValue1 argument1, TValue2 argument2, System.String callbackName, System.Object context) (at Library/PackageCache/com.unity.inputsystem@1.5.1/InputSystem/Utilities/DelegateHelpers.cs:71)
UnityEngine.InputSystem.BindingSyntax:InsertPartBinding(String, String)
ControlPresetUI:UpdateSignatureActivation() (at Assets/Scripts/UI/Main Menu/Control Presets/ControlPresetUI.cs:222)
ControlPresetUI:DecrementSignatureActivation() (at Assets/Scripts/UI/Main Menu/Control Presets/ControlPresetUI.cs:156)
UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:385)

If I switch the orders of the same ChangeCompositeBinding functions, I get the same error (though with a line change for ControlPresetUI.cs). It seems the issue is in the way I’m using InsertPartBinding (the action seemingly doesn’t exist). I want to insert a new binding into an existing composite. Is there anyway I can do this?