Skip to content

DEVXT-1965 remove users from enterprise - #36

Open
MonicaG wants to merge 3 commits into
mainfrom
remove-users
Open

DEVXT-1965 remove users from enterprise#36
MonicaG wants to merge 3 commits into
mainfrom
remove-users

Conversation

@MonicaG

@MonicaG MonicaG commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

This PR does the following:

  • Remove users from the GitHub enterprise
  • Users are provided in an input file
  • Supports running in a debug mode by default (users are not removed)
  • Use the --remove flag to actually remove the users
  • Prompts user for confirmation before running

@MonicaG
MonicaG requested a lite review from Copilot August 20, 2026 17:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Node.js CLI utility under utils/github/ent-remove-users to remove members from a GitHub Enterprise based on usernames listed in a CSV file, with a dry-run default and an explicit --remove opt-in for destructive behavior.

Changes:

  • Implemented the CLI flow (CSV parsing, confirmation prompt, GraphQL lookups, and enterprise-member removal).
  • Added an Octokit factory configured with throttling/retry behavior.
  • Added project scaffolding (README, Node engine pinning, dependencies, and ignore rules).

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
utils/github/ent-remove-users/src/index.js CLI entrypoint: parses args, reads CSV, confirms, and performs (or simulates) removals via GraphQL.
utils/github/ent-remove-users/src/octokit.js Creates a throttled Octokit client and defines rate-limit handling callbacks.
utils/github/ent-remove-users/src/logger.js Introduces a pino logger used across the utility.
utils/github/ent-remove-users/README.md Documents purpose, prerequisites, usage, and CSV format.
utils/github/ent-remove-users/package.json Defines package metadata, scripts, dependencies, and Node engine requirement.
utils/github/ent-remove-users/package-lock.json Locks dependency versions for repeatable installs.
utils/github/ent-remove-users/.tool-versions Pins Node.js toolchain version for local dev tooling.
utils/github/ent-remove-users/.gitignore Ignores logs, CSVs, and node_modules for the utility directory.
Files not reviewed (1)
  • utils/github/ent-remove-users/package-lock.json: Generated file
Suppressed comments (1)

utils/github/ent-remove-users/src/index.js:187

  • pino loggers don't reliably log additional arguments; logger.error('...', error) will typically drop the error object/stack. Use pino’s error logging signature so the exception details are recorded.
    logger.error('An unexpected error occurred:', error);

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread utils/github/ent-remove-users/src/logger.js
Comment thread utils/github/ent-remove-users/src/octokit.js
Comment thread utils/github/ent-remove-users/src/octokit.js
Comment thread utils/github/ent-remove-users/src/index.js

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • utils/github/ent-remove-users/package-lock.json: Generated file
Suppressed comments (3)

Previously missed (3) — in code that hasn't changed since the last review.

utils/github/ent-remove-users/src/index.js:170

  • The --file validation uses await fs.stat(file) inside the if condition. If the path does not exist or is unreadable, fs.stat throws and the script will crash before printing the intended error message / setting process.exitCode.

Handle the fs.stat failure explicitly and treat it as an invalid file.

  if (!file || !(await fs.stat(file)).isFile()) {
    console.error('Error:  --file must be specified and must be a valid file.');
    process.exitCode = 1;
    return;
  }

utils/github/ent-remove-users/src/index.js:158

  • parseArgs(...) can throw (e.g., unknown flag, missing value when strict: true). Because this runs before the main try/catch, the script will exit with a stack trace instead of a user-friendly message.

Wrap argument parsing in a try/catch and exit cleanly on invalid CLI input.

  const {
    values,
  } = parseArgs({ options, strict: true, allowPositionals: false });

utils/github/ent-remove-users/src/index.js:191

  • logger.error('An unexpected error occurred:', error) passes the Error as a second formatting argument, which typically loses structured error fields/stack in pino output.

Log the error as an err object so the stack trace is preserved.

  } catch (error) {
    logger.error('An unexpected error occurred:', error);
    process.exitCode = 1;
  }

Comment thread utils/github/ent-remove-users/src/logger.js
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.

2 participants