Skip to content

Updates for #4820#4824

Merged
lukaszgryglicki merged 2 commits intodevfrom
unicron-4820
Oct 14, 2025
Merged

Updates for #4820#4824
lukaszgryglicki merged 2 commits intodevfrom
unicron-4820

Conversation

@lukaszgryglicki
Copy link
Member

cc @mlehotskylf @jarias-lfx @ahmedomosanya

Signed-off-by: Lukasz Gryglicki lgryglicki@cncf.io

Assisted by OpenAI

Assisted by GitHub Copilot

Signed-off-by: Lukasz Gryglicki <lgryglicki@cncf.io>

Assisted by [OpenAI](https://platform.openai.com/)

Assisted by [GitHub Copilot](https://github.com/features/copilot)
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses issue #4820 by adding debugging utilities for GitHub PAT (Personal Access Token) permissions and fixing a GitHub client authentication issue in the merge group status functionality.

  • Added utility scripts for testing GitHub PAT GraphQL permissions and copying production data
  • Fixed GitHub client authentication in update_merge_group_status method
  • Added a helper script for setting GitHub OAuth tokens

Reviewed Changes

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

File Description
utils/github_pat_check.sh New debugging script to test GitHub PAT GraphQL permissions with comprehensive API endpoint checks
utils/copy_prod_case_7.sh New utility script for copying specific repository data from production to development
set-easycla-github-token.sh Simple helper script to export GitHub OAuth token from secret file
cla-backend/cla/models/github_models.py Fixed GitHub client initialization to use proper integration client instead of broken authentication

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@coderabbitai
Copy link

coderabbitai bot commented Oct 14, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Switches GitHub client initialization in update_merge_group_status to use get_github_integration_client. Adds three Bash utilities: exporting a GitHub OAuth token from a secret file, copying a specific production repo to dev, and a GitHub PAT checker that runs several GraphQL-based validations.

Changes

Cohort / File(s) Summary
GitHub client init change
cla-backend/cla/models/github_models.py
Replaces _get_github_client with get_github_integration_client in update_merge_group_status; rest of control flow and error handling unchanged.
New token export script
set-easycla-github-token.sh
New script exporting GITHUB_OAUTH_TOKEN from ./easycla-github-oauth-token.secret.
Prod-to-dev copy utility
utils/copy_prod_case_7.sh
New script: scans prod for fluxnova-modeler repository_id, calls copy_prod_to_dev.sh with it, then rescans dev to verify.
GitHub PAT check utility
utils/github_pat_check.sh
New script that validates a PAT via GraphQL and REST: viewer query, OAuth scopes header check, repository access query, and PR commit fetch; includes usage and arg checks.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Worker as Caller
  participant GM as GitHubModels.update_merge_group_status
  participant GIC as GitHub Integration Client
  participant GH as GitHub API

  Worker->>GM: update_merge_group_status(installation_id, ...)
  alt Client not initialized
    GM->>GIC: get_github_integration_client(installation_id)
    GIC-->>GM: client
  else Client initialized
    GM-->>GM: reuse existing client
  end
  GM->>GH: Fetch repo and commit status
  GH-->>GM: Status data
  GM-->>Worker: Return/update status
  note over GM,GIC: Changed: initialization path uses integration client
Loading
sequenceDiagram
  autonumber
  actor User
  participant Script as utils/github_pat_check.sh
  participant GQL as GitHub GraphQL API
  participant REST as GitHub REST (headers)

  User->>Script: ./github_pat_check.sh <token> <org> <repo> <pr>
  Script-->>User: Print token preview
  Script->>GQL: Query { viewer { login } }
  GQL-->>Script: viewer.login
  Script->>REST: GET / (retrieve headers)
  REST-->>Script: X-OAuth-Scopes
  Script->>GQL: Query repository(owner, name) { id }
  GQL-->>Script: repository id
  Script->>GQL: Query pullRequest(number) { commits(first:1){nodes{commit{oid}}}}
  GQL-->>Script: first commit oid
  Script-->>User: Print results per step
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description only lists reviewer mentions, a sign-off, and AI assistance acknowledgments without any summary of the actual code changes, making it unrelated to the modifications in this PR. Please update the description to include a concise summary of the changes, such as switching to get_github_integration_client for client initialization and introducing the new shell scripts for GitHub token setup and PAT permission checks.
Title Check ❓ Inconclusive The title “Updates for #4820” is too generic and does not describe the main changes such as using the GitHub integration client in merge group status or adding new utility scripts, so it fails to inform reviewers about the core updates. Consider renaming the title to clearly reflect the primary changes, for example “Use GitHub integration client in merge group status and add utility scripts for token and PAT validation,” so the purpose of the PR is immediately evident.
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch unicron-4820

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d86737e and c32c305.

📒 Files selected for processing (2)
  • cla-backend/cla/models/github_models.py (1 hunks)
  • utils/github_pat_check.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • cla-backend/cla/models/github_models.py
  • utils/github_pat_check.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build-test-lint
  • GitHub Check: cypress-functional

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (3)
cla-backend/cla/models/github_models.py (1)

710-712: Remove commented-out code.

The fix is correct—switching to get_github_integration_client(installation_id) properly initializes the GitHub App client. However, the comment on line 710 and the commented-out code on line 711 should be removed to avoid clutter.

Apply this diff:

-        # LG: this was creating broken/partially authenticated client
-        # self.client = self._get_github_client(installation_id)
         self.client = get_github_integration_client(installation_id)
utils/github_pat_check.sh (2)

21-43: Add error handling to curl commands.

The script continues executing subsequent tests even if earlier ones fail, which can produce misleading diagnostics.

Consider adding set -euo pipefail at the top, or check each curl's exit status:

#!/bin/bash
set -euo pipefail

# ... existing validation ...

echo -e "\n1. Testing Simple GraphQL Query:"
echo "--------------------------------"
if ! curl -s -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -d '{"query":"query { viewer { login } }"}' \
     https://api.github.com/graphql; then
  echo "Error: Simple GraphQL query failed" >&2
  exit 1
fi

# ... repeat for remaining tests ...

17-17: Avoid logging token fragments.

Even partial token values pose a security risk if logs are inadvertently exposed.

Apply this diff:

-echo "Testing GitHub PAT GraphQL with token: ${TOKEN:0:10} for $ORG/$REPO PR:$PR..."
+echo "Testing GitHub PAT GraphQL for $ORG/$REPO PR:$PR..."
🧹 Nitpick comments (2)
utils/copy_prod_case_7.sh (1)

2-4: Add error handling and validation.

The script lacks safeguards: if scan.sh fails or returns unexpected output, repo_id could be empty or invalid, causing copy_prod_to_dev.sh to behave unpredictably.

Apply this diff to add error handling:

 #!/bin/bash
+set -euo pipefail
+
 repo_id=$(STAGE=prod ./utils/scan.sh repositories repository_name 'fluxnova-modeler' | jq -r '.[0].repository_id.S')
+if [[ -z "$repo_id" || "$repo_id" == "null" ]]; then
+  echo "Error: Failed to retrieve repository_id for fluxnova-modeler" >&2
+  exit 1
+fi
+echo "Retrieved repository_id: $repo_id"
+
 ./utils/copy_prod_to_dev.sh repositories repository_id "${repo_id}"
 STAGE=dev ./utils/scan.sh repositories repository_name 'fluxnova-modeler'
utils/github_pat_check.sh (1)

6-16: Validate input format.

The script accepts any string for the token and PR number without checking format. A malformed token or non-numeric PR could cause unexpected behavior or security issues.

Add basic validation after line 16:

# Validate token format (GitHub PATs start with ghp_ or similar)
if [[ ! "$TOKEN" =~ ^(ghp_|gho_|ghu_|ghs_|ghr_) ]]; then
  echo "Warning: Token does not match expected GitHub PAT format" >&2
fi

# Validate PR is numeric
if [[ ! "$PR" =~ ^[0-9]+$ ]]; then
  echo "Error: PR number must be numeric, got: $PR" >&2
  exit 1
fi
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5296a0e and d86737e.

📒 Files selected for processing (4)
  • cla-backend/cla/models/github_models.py (1 hunks)
  • set-easycla-github-token.sh (1 hunks)
  • utils/copy_prod_case_7.sh (1 hunks)
  • utils/github_pat_check.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.11.0)
set-easycla-github-token.sh

[warning] 2-2: Declare and assign separately to avoid masking return values.

(SC2155)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: cypress-functional
  • GitHub Check: build-test-lint

Signed-off-by: Lukasz Gryglicki <lgryglicki@cncf.io>

Assisted by [OpenAI](https://platform.openai.com/)

Assisted by [GitHub Copilot](https://github.com/features/copilot)
@lukaszgryglicki lukaszgryglicki merged commit eaaa1dc into dev Oct 14, 2025
4 of 6 checks passed
@lukaszgryglicki lukaszgryglicki deleted the unicron-4820 branch October 14, 2025 07:57
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.

3 participants