pcottle/learnGitBranching · error · GitError

Bad numeric argument: ' + generalArgs[1]

Error message

Bad numeric argument: ' + generalArgs[1]

What it means

fakeTeamwork's two-arg form parses generalArgs[1] as a count; parseInt yields NaN so the argument isn't numeric and a GitError with a plain (non-i18n) message is thrown.

Source

Thrown at src/js/git/commands.js:366

          branch = 'main';
          numToMake = 1;
          break;

        // git fakeTeamwork 10 or git fakeTeamwork foo
        case 1:
          if (isNaN(parseInt(generalArgs[0], 10))) {
            branch = validateOriginBranchName(engine, generalArgs[0]);
            numToMake = 1;
          } else {
            numToMake = parseInt(generalArgs[0], 10);
            branch = 'main';
          }
          break;

        case 2:
          branch = validateOriginBranchName(engine, generalArgs[0]);
          if (isNaN(parseInt(generalArgs[1], 10))) {
            throw new GitError({
              msg: 'Bad numeric argument: ' + generalArgs[1]
            });
          }
          numToMake = parseInt(generalArgs[1], 10);
          break;

      }

      // make sure its a branch and exists
      var destBranch = engine.origin.resolveID(branch);
      if (destBranch.get('type') !== 'branch') {
        throw new GitError({
          msg: intl.str('git-error-options')
        });
      }

      engine.fakeTeamwork(numToMake, branch);
    }

View on GitHub (pinned to 5b09d0ff96)

Solutions

  1. Pass a numeric count: git fakeTeamwork <branch> <number>
  2. Reorder args — branch first, integer count second

Example fix

// before
git fakeTeamwork two main
// after
git fakeTeamwork main 2
Defensive patterns

Strategy: validation

Validate before calling

var n = parseInt(args[1], 10); if (isNaN(n)) { prompt for a number; return; }

Type guard

function isCountArg(s) { return /^\d+$/.test(String(s)); }

Prevention

When it happens

Trigger: git fakeTeamwork main abc or git fakeTeamwork main two.

Common situations: Passing the branch and count in the wrong order; typing a word instead of a number.

Related errors


AI-assisted analysis of pcottle/learnGitBranching@5b09d0ff96 (2026-08-27). Data as JSON: /api/errors/dc1323297e9e1570. Report an issue: GitHub.