Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update code to support @octokit/request v9 and @octokit/graphql v8 #3705

Closed

Conversation

Recxsmacx
Copy link

@Recxsmacx Recxsmacx commented Feb 18, 2025

Fixes #3690

[Update code to support @octokit/request v9.2.2 and @octokit/graphql v8.2.1.](fix: update code to support @octokit/request v9 and @octokit/graphql v8)

  • netlify/functions/github_discussions.ts

    • Remove unused import of GraphQlQueryResponseData.
    • Update graphql function call to use the new syntax.
    • Update authorization header to use the new token format.
  • netlify/functions/save-discussion-background/helpers.ts

    • Update authorization header to use the new token format.

Summary by CodeRabbit

Summary by CodeRabbit

  • Chores
    • Enhanced automated performance report archiving to ensure consistent monitoring.
  • Refactor
    • Streamlined authentication for discussion features, boosting overall integration reliability.
    • Improved clarity and organization of GraphQL request handling.

Fixes asyncapi#3690

Update code to support `@octokit/request` v9.2.2 and `@octokit/graphql` v8.2.1.

* **netlify/functions/github_discussions.ts**
  - Remove unused import of `GraphQlQueryResponseData`.
  - Update `graphql` function call to use the new syntax.
  - Update authorization header to use the new token format.

* **netlify/functions/save-discussion-background/helpers.ts**
  - Update authorization header to use the new token format.
Copy link
Contributor

coderabbitai bot commented Feb 18, 2025

Warning

Rate limit exceeded

@Recxsmacx has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 27 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between b0270e9 and bbedede.

📒 Files selected for processing (1)
  • .github/workflows/lighthouse-ci.yml (3 hunks)

Walkthrough

This pull request introduces changes in two areas. In the GitHub Actions workflow for Lighthouse CI, a new always-run step for uploading Lighthouse report artifacts has been added, complete with a specified retention period and error-handling configuration. In two Netlify function files, the GraphQL request structure was refined, with adjustments including the removal of an import and an update to the authorization header format—from using the token prefix to Bearer.

Changes

File(s) Change Summary
.github/workflows/lighthouse-ci.yml Added an "Upload artifacts" step for Lighthouse reports that always runs, uploads artifacts from a specified path, sets a 5-day retention, and continues on error.
netlify/functions/github_discussions.ts
netlify/functions/save-discussion-background/helpers.ts
Refactored GraphQL request structure: removed an unused import, encapsulated the mutation query in an object, and updated the authorization header format to use Bearer instead of token.

Sequence Diagram(s)

sequenceDiagram
    participant CI as GitHub Actions
    participant Lighthouse as Lighthouse Audit
    participant Upload as Upload Artifacts Step

    Note over CI: Workflow Triggered
    CI->>Lighthouse: Run Lighthouse Audit
    Lighthouse-->>CI: Generate Lighthouse Report
    CI->>Upload: Execute Upload Artifacts (always runs)
    Upload-->>CI: Upload "lighthouse-report" (5-day retention)
Loading

Suggested reviewers

  • derberg
  • devilkiller-ag
  • akshatnema
  • sambhavgupta0705
  • anshgoyalevil
  • Mayaleeeee

Poem

I'm a bunny with lines so neat,
Hopping through code, light on my feet.
Artifacts uploaded in a careful flight,
Tokens now bear "Bearer" in the light.
With clear GraphQL hops, I cheer the code delight!
🐰✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@asyncapi-bot
Copy link
Contributor

Hello, @coderabbitai[bot]! 👋🏼

    I'm 🧞🧞🧞 Genie 🧞🧞🧞 from the magic lamp. Looks like somebody needs a hand!

    At the moment the following comments are supported in pull requests:

    - `/please-take-a-look` or `/ptal` - This comment will add a comment to the PR asking for attention from the reviewrs who have not reviewed the PR yet.
    - `/ready-to-merge` or `/rtm` - This comment will trigger automerge of PR in case all required checks are green, approvals in place and do-not-merge label is not added
    - `/do-not-merge` or `/dnm` - This comment will block automerging even if all conditions are met and ready-to-merge label is added
    - `/autoupdate` or `/au` - This comment will add `autoupdate` label to the PR and keeps your PR up-to-date to the target branch's future changes. Unless there is a merge conflict or it is a draft PR. (Currently only works for upstream branches.)
    - `/update` or `/u` - This comment will update the PR with the latest changes from the target branch. Unless there is a merge conflict or it is a draft PR. NOTE: this only updates the PR once, so if you need to update again, you need to call the command again.

Copy link

netlify bot commented Feb 18, 2025

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit bbedede
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/67b483fa158e070008842de5
😎 Deploy Preview https://deploy-preview-3705--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

coderabbitai bot commented Feb 18, 2025

Tip

For best results, initiate chat on the files or code changes.


🧠 Learnings used
Learnt from: asyncapi-bot
PR: asyncapi/website#0
File: :0-0
Timestamp: 2025-02-18T12:07:42.211Z
Learning: The following PR commands are supported in the asyncapi/website repository:
- `/please-take-a-look` or `/ptal`: Requests attention from reviewers who haven't reviewed the PR
- `/ready-to-merge` or `/rtm`: Triggers automerge when all conditions are met
- `/do-not-merge` or `/dnm`: Blocks automerge even if all conditions are met
- `/autoupdate` or `/au`: Adds autoupdate label to keep PR in sync with target branch
- `/update` or `/u`: One-time update of PR with latest changes from target branch

@asyncapi-bot
Copy link
Contributor

@derberg @devilkiller-ag @akshatnema @sambhavgupta0705 @anshgoyalevil @Mayaleeeee Please take a look at this PR. Thanks! 👋

Copy link

codecov bot commented Feb 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (b1c7f7c) to head (bbedede).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #3705   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           20        20           
  Lines          732       732           
=========================================
  Hits           732       732           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@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: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b1c7f7c and e5fef4e.

📒 Files selected for processing (3)
  • .github/workflows/lighthouse-ci.yml (1 hunks)
  • netlify/functions/github_discussions.ts (1 hunks)
  • netlify/functions/save-discussion-background/helpers.ts (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/lighthouse-ci.yml

99-99: the runner of "actions/upload-artifact@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

⏰ Context from checks skipped due to timeout of 180000ms (1)
  • GitHub Check: Test NodeJS PR - macos-13
🔇 Additional comments (2)
netlify/functions/github_discussions.ts (2)

27-40: LGTM! GraphQL query structure improved.

The restructured GraphQL query with a dedicated object parameter improves code organization and aligns with @octokit/graphql v8 requirements.


37-37: LGTM! Authorization header updated consistently.

The change from token to Bearer prefix maintains consistency with the helper file and aligns with OAuth 2.0 standards.

@@ -18,7 +18,7 @@ export function toTitleCase(title: string): string {
export async function fetchGraphql(query: string): Promise<any> {
const parameters = {
headers: {
authorization: `token ${process.env.GITHUB_TOKEN}`,
authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

LGTM! Authorization header updated to OAuth 2.0 standard format.

The change from token to Bearer prefix aligns with the OAuth 2.0 standard and the requirements of @octokit/graphql v8.


🏁 Script executed:

#!/bin/bash
# Description: Verify that all GitHub API calls use Bearer token format

# Test: Search for any remaining token-based auth. Expect: No occurrences.
rg -i 'authorization.*token\s+\$'

Length of output: 545


FYI: Inconsistencies detected – further updates required for consistent OAuth 2.0 token usage.

LGTM for the changes in netlify/functions/save-discussion-background/helpers.ts where the Authorization header was updated to use the Bearer prefix in line with OAuth 2.0 and @octokit/graphql v8 requirements. However, our verification script found several other locations still using the old token prefix for the Authorization header. Please review and update the following files for consistency, unless these occurrences are intentionally exempted:

  • netlify/edge-functions/serve-definitions.ts: Contains originalRequest.headers.set('Authorization', \token ${GITHUB_TOKEN}`);`
  • tests/tools/extract-tools-github.test.js: Uses authorization: \token ${process.env.GITHUB_TOKEN}``
  • scripts/dashboard/build-dashboard.js: Contains multiple instances of authorization: \token ${process.env.GITHUB_TOKEN}``
  • scripts/tools/extract-tools-github.js: Uses authorization: \token ${process.env.GITHUB_TOKEN}``

Please address these inconsistencies to ensure a uniform authentication method across the codebase.

Comment on lines 97 to 104
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v2
with:
name: lighthouse-report
path: ./path/to/lighthouse/report
retention-days: 5
continue-on-error: true
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

⚠️ Potential issue

🧩 Analysis chain

Update action version and verify artifact path.

The artifact upload step is a good addition, but there are a few issues to address:

  1. The action version is outdated. Update to the latest version.
  2. The artifact path seems generic and might not be correct.

Apply these changes:

-        uses: actions/upload-artifact@v2
+        uses: actions/upload-artifact@v4
-          path: ./path/to/lighthouse/report
+          path: ./lhci_reports

Note: Please verify that the path matches the actual location where Lighthouse CI generates its reports.


🏁 Script executed:

#!/bin/bash
# Description: Check if Lighthouse report path exists in the configuration

# Test: Search for Lighthouse report path in config. Expect: Path definition.
rg -l 'lhci.*report|lighthouse.*report' .github/

Length of output: 86


Update the artifact upload configuration.

The artifact upload step is a great addition, but please address two concerns:

  • Action version: The currently used version (actions/upload-artifact@v2) is outdated. Please update it to the latest version (actions/upload-artifact@v4).
  • Artifact path: The configured path (./path/to/lighthouse/report) appears overly generic. Ensure it accurately reflects the directory where Lighthouse CI generates its reports. For instance, if reports are generated in ./lhci_reports, adjust the path accordingly.

Apply these changes:

-        uses: actions/upload-artifact@v2
+        uses: actions/upload-artifact@v4
-          path: ./path/to/lighthouse/report
+          path: ./lhci_reports

Please verify that the updated artifact path aligns with the actual report output directory in your configuration.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v2
with:
name: lighthouse-report
path: ./path/to/lighthouse/report
retention-days: 5
continue-on-error: true
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: lighthouse-report
path: ./lhci_reports
retention-days: 5
continue-on-error: true
🧰 Tools
🪛 actionlint (1.7.4)

99-99: the runner of "actions/upload-artifact@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

@Recxsmacx Recxsmacx changed the title fix: Update code to support @octokit/request v9 and @octokit/graphql v8 fix: update code to support @octokit/request v9 and @octokit/graphql v8 Feb 18, 2025
@Recxsmacx Recxsmacx closed this Feb 18, 2025
@Recxsmacx Recxsmacx reopened this Feb 18, 2025
Copy link
Contributor

@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

🔭 Outside diff range comments (1)
.github/workflows/lighthouse-ci.yml (1)

97-105: 🛠️ Refactor suggestion

⚠️ Potential issue

Fix YAML Indentation and Update Artifact Upload Action Version

The "Upload artifacts" step (lines 97–105) is currently suffering from inconsistent indentation in its with: block. Specifically, the keys name and path (lines 101–102) are indented more than retention-days and continue-on-error (lines 103–104), which leads to a syntax error. Moreover, the step is still using actions/upload-artifact@v2, which is outdated. It is advisable to update to actions/upload-artifact@v4 and adjust the indentation so that all keys under with: are uniformly indented.

A suggested diff is as follows:

-      - name: Upload artifacts
-        if: always()
-        uses: actions/upload-artifact@v2
-        with:
-            name: lighthouse-report
-            path: path/to/artifact
-          retention-days: 5
-          continue-on-error: true
+      - name: Upload artifacts
+        if: always()
+        uses: actions/upload-artifact@v4
+        with:
+          name: lighthouse-report
+          path: path/to/artifact
+          retention-days: 5
+          continue-on-error: true

This change will fix the YAML syntax and ensure that the workflow uses the latest supported version of the artifact upload action.

🧰 Tools
🪛 YAMLlint (1.35.1)

[warning] 101-101: wrong indentation: expected 10 but found 12

(indentation)


[error] 103-103: syntax error: expected , but found ''

(syntax)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e5fef4e and b0270e9.

📒 Files selected for processing (1)
  • .github/workflows/lighthouse-ci.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/lighthouse-ci.yml

96-96: could not parse as YAML: yaml: line 96: did not find expected key

(syntax-check)

🪛 YAMLlint (1.35.1)
.github/workflows/lighthouse-ci.yml

[warning] 101-101: wrong indentation: expected 10 but found 12

(indentation)


[error] 103-103: syntax error: expected , but found ''

(syntax)

⏰ Context from checks skipped due to timeout of 180000ms (5)
  • GitHub Check: Redirect rules - asyncapi-website
  • GitHub Check: Header rules - asyncapi-website
  • GitHub Check: Pages changed - asyncapi-website
  • GitHub Check: Test NodeJS PR - windows-latest
  • GitHub Check: Test NodeJS PR - macos-13

@@ -93,3 +93,12 @@ jobs:
number: ${{ github.event.pull_request.number }}
header: lighthouse
message: ${{ steps.lighthouse_score_report.outputs.comment }}

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove Extraneous Marker Causing YAML Parse Error

Line 96 appears to contain an extraneous marker (a lone ~ or similar) which is triggering a YAML parsing error ("did not find expected key"). Please remove this line to resolve the syntax issue.

🧰 Tools
🪛 actionlint (1.7.4)

96-96: could not parse as YAML: yaml: line 96: did not find expected key

(syntax-check)

@Recxsmacx
Copy link
Author

@anshgoyalevil bro please check this one!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix: Update code to support @octokit/request v9 and @octokit/graphql v8
2 participants