Skip to content

Conversation

@lykimq
Copy link
Contributor

@lykimq lykimq commented Nov 5, 2025

Depend on #352

  • Remove all the code related to bot installation using PAT (mentioned as legacy in README.md):
    • no GITHUB_ACCESS_TOKEN usage in source code
    • Bot_info.github_token requires installation token and fails if missing
  • Update documentation:
    • README.md: remove GITHUB_ACCESS_TOKEN, section As a regular user account (legacy)
    • example-config.toml: remove github.api_token
  • Test coverage:
    • test/test_bot_info: tests installation token usage and failure when missing
    • test/test_webhook: tests webhook parsing with and without installation.id

@lykimq lykimq force-pushed the quyen@remove_legacy_isntallation branch from ff51f3a to 600d086 Compare November 14, 2025 11:17
@Zimmi48
Copy link
Member

Zimmi48 commented Nov 19, 2025

There are still some commits that look like they are coming from previous PRs, making the diff view less usable to review this particular PR.

Comment on lines 113 to 119
let init_git_bare_repository ~bot_info =
let* () = Lwt_io.printl "Initializing repository..." in
let github_token = Bot_info.github_token bot_info in
"git init --bare"
|&& f {|git config user.email "%s"|} bot_info.email
|&& f {|git config user.name "%s"|} bot_info.github_name
|> execute_cmd ~mask:[bot_info.github_pat] (* TODO: direct PAT usage *)
|> execute_cmd ~mask:[github_token]
Copy link
Member

Choose a reason for hiding this comment

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

In this case, I think we should just simplify this by removing the ~mask argument (which probably served no purpose in this case).

Comment on lines 1390 to 1393
(* To delete the branch we need to identify as
coqbot the GitHub user, who is a collaborator on
the run-coq-bug-minimizer repo, not coqbot the
GitHub App *)
(* TODO: direct PAT usage *)
(f "git push https://%s:%[email protected]/%s.git --delete '%s"
bot_info.github_name bot_info.github_pat repo_name
branch_name )
bot_info.github_name
(Bot_info.github_token bot_info)
repo_name branch_name )
Copy link
Member

Choose a reason for hiding this comment

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

I was looking for things like this: here the reason for the direct PAT usage is precisely that we need to do this action as a GitHub account rather than as a GitHub App. So the GitHub PAT should actually not be removed, but its use should be confined to these very specific use cases.

Comment on lines 8 to +24
(* To push a new branch we need to identify as coqbot the GitHub
user, who is a collaborator on the run-coq-bug-minimizer repo,
not coqbot the GitHub App *)
let github_token = github_token bot_info in
Stdlib.Filename.quote_command "./coq_bug_minimizer.sh"
[ script
; GitHub_ID.to_string comment_thread_id
; comment_author
; bot_info.github_pat
; github_token
; bot_info.github_name
; bot_info.domain
; owner
; repo
; coq_version
; ocaml_version
; String.concat ~sep:" " minimizer_extra_arguments ]
|> execute_cmd ~mask:[bot_info.github_pat]
|> execute_cmd ~mask:[github_token]
Copy link
Member

Choose a reason for hiding this comment

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

Again, this is a legitimate use of the GitHub PAT (as explained by the comment). (And same thing, later in this file.)

"[WARNING: Legacy Mode] Webhook received WITHOUT installation.id - \n\n\
\ Will attempt PAT fallback (will fail with invalid token)" )
"[INFO] Webhook received without installation.id (legacy webhook \
format, GitHub App installation required for actions)" )
Copy link
Member

Choose a reason for hiding this comment

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

Why not turn this into an error?

Comment on lines 3 to +20
type t =
{ gitlab_instances: (string, string * string) Hashtbl.t
; github_pat: string
; github_install_token: string option
; github_name: string
; email: string
; domain: string
; app_id: int }

(* Returns the GitHub installation token. Requires installation token to be set. *)
let github_token bot_info =
match bot_info.github_install_token with
| Some t ->
t
| None ->
bot_info.github_pat
(* TODO: use Result.t later *)
failwith
"GitHub installation token is required. Please ensure the GitHub App \
is installed and an installation token is available."
Copy link
Member

Choose a reason for hiding this comment

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

Avoid leaving exceptions in finished code except in very specific cases. Here, my suggestion is that instead of handling the case where github_install_token is None, we just make it a mandatory parameter, just like github_name, etc.
OTOH, github_pat is the one which we want to make optional, just for the few legitimate uses (that are all specific to the Rocq minimization feature). Since the function github_token then becomes trivial, it can just be replaced by direct use of .github_install_token.

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.

4 participants