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

DEVXT-1941 GitHub Discussions Search #191

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

minkimcello
Copy link

@minkimcello minkimcello commented Nov 19, 2024

  • Installed the discussions search collator to the backend
  • Created a custom list component for discussions with author/label chips

Configuring the collator

The collator can be configured through your app-config.yaml file. The descriptions for each configurable property can be found in the plugin's config.d.ts.

If you want to specify your own location for cache, it must be in the format of a file URL with a trailing slash:

# app-config.local.yaml

search:
  collators:
    githubDiscussions:
+      cacheBase: file:///path/to/project/developer-portal/.cache/

And you'll probably want to add that directory to your .gitignore too.

Generating Tarball

While we wait for my pull request to be merged, I packaged the search collator module into a tarball and added it to this pull request. I had to make a few minor changes to get it to package successfully, you can see those changes in this commit.

You can track the progress of the upstream pull request here: https://github.com/backstage/community-plugins/pulls?q=is%3Apr+is%3Aopen+GitHub+Discussions+Search+Collator

If there are any changes you'd like to see (before the upstream PR is merged), I can show you how to create new tarballs from your local changes. There are some caveats with yarn and its local caching mechanism that you would need to be mindful of. Or you can always ask me to create new tarballs with the changes you want to see.

Permissions

You might have noticed in the commit I linked above, I have configured a permission for the collator:

this.visibilityPermission = createPermission({
  name: 'search.discussions.read',
  attributes: {
    action: 'read',
  },
  resourceType: 'github-discussions',
});

You'll be able to write your own policy using that permission name:

// permissionsPolicyExtension.ts

if (
  request.permission.name === 'search.discussions.read' &&
  user.identity.userEntityRef !== 'user:default/guest'
) {
  return {
    result: AuthorizeResult.ALLOW,
  };
} else {
  return {
    result: AuthorizeResult.DENY,
  };
}

@MonicaG
Copy link
Contributor

MonicaG commented Nov 29, 2024

Hi @minkimcello,

I'm trying to run this locally but am getting the following error:

/Users/mgranboi/development/developer-portal/node_modules/github-discussions-fetcher/script/lib/useRetryWithBackoff.js:121
[1] undefined
[1]       ^
[1]
[1] Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/mgranboi/development/developer-portal/node_modules/pretty-ms/index.js from /Users/mgranboi/development/developer-portal/node_modules/github-discussions-fetcher/script/lib/useRetryWithBackoff.js not supported.
[1] Instead change the require of index.js in /Users/mgranboi/development/developer-portal/node_modules/github-discussions-fetcher/script/lib/useRetryWithBackoff.js to a dynamic import() which is available in all CommonJS modules.
[1]     at Object.newLoader [as .js] (/Users/mgranboi/development/developer-portal/node_modules/pirates/lib/index.js:121:7)
[1]     at Object.<anonymous> (/Users/mgranboi/development/developer-portal/node_modules/github-discussions-fetcher/script/lib/useRetryWithBackoff.js:11:37)
[1]     at Object.newLoader [as .js] (/Users/mgranboi/development/developer-portal/node_modules/pirates/lib/index.js:121:7)
[1]     at Object.<anonymous> (/Users/mgranboi/development/developer-portal/node_modules/github-discussions-fetcher/script/lib/useGraphQL.js:17:34) {
[1]   code: 'ERR_REQUIRE_ESM'
[1] }
[1]
[1] Node.js v20.18.1

I've tried deleting my node_modules/ and then did a yarn install, which didn't resolve the issue.

Here is the contents of the /Users/mgranboi/development/developer-portal/node_modules/github-discussions-fetcher/script/lib/useRetryWithBackoff.js file:

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.useRetryWithBackoff = useRetryWithBackoff;
exports.initRetryWithBackoff = initRetryWithBackoff;
const effection_1 = require("effection");
const useLogger_js_1 = require("./useLogger.js");
const ensureContext_js_1 = require("./ensureContext.js");
const pretty_ms_1 = __importDefault(require("pretty-ms"));
const RetryWithBackoffContext = (0, effection_1.createContext)("retry-with-context");
function* useRetryWithBackoff(fn, options) {
    const logger = yield* (0, useLogger_js_1.useLogger)();
    const defaults = yield* RetryWithBackoffContext.expect();
    const _options = {
        ...defaults,
        ...options,
    };
    let attempt = -1;
    function* body() {
        while (true) {
            try {
                const result = yield* fn();
                if (attempt !== -1) {
                    logger.log(`Operation[${_options.operationName}] succeeded after ${attempt + 2} retry.`);
                }
                return result;
            }
            catch (e) {
                // https://aws.amazon.com/ru/blogs/architecture/exponential-backoff-and-jitter/
                const backoff = Math.pow(2, attempt) * 1000;
                const delayMs = Math.round((backoff * (1 + Math.random())) / 2);
                // logger.debug(e);
                logger.log(`Operation[${_options.operationName}] failed, will retry in ${(0, pretty_ms_1.default)(delayMs)}.`);
                yield* (0, effection_1.sleep)(delayMs);
                attempt++;
            }
        }
    }
    function* timeout() {
        yield* (0, effection_1.sleep)(_options.timeout ?? defaults.timeout);
        logger.log(`Operation[${_options.operationName}] timedout after ${attempt + 2}`);
    }
    yield* (0, effection_1.race)([
        body(),
        timeout(),
    ]);
}
function* initRetryWithBackoff(defaults) {
    // deno-lint-ignore require-yield
    function* init() {
        return defaults;
    }
    return yield* (0, ensureContext_js_1.ensureContext)(RetryWithBackoffContext, init());
}
//# sourceMappingURL=useRetryWithBackoff.js.map

@minkimcello
Copy link
Author

@MonicaG oh that's odd. pretty-ms wasn't included as a dependency in the fetcher for some reason. I'll fix that now

@minkimcello
Copy link
Author

@MonicaG What version do you see when you run yarn why @guidanti/backstage-github-discussions-fetcher?

Copy link
Contributor

@MonicaG MonicaG left a comment

Choose a reason for hiding this comment

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

HI @minkimcello, Just some general questions I had when first looking at the code. I'll try running it locally with yourpretty-ms fix and will probably have more questions after that. Looks good overall though! 🚀

style={{
display: '-webkit-box',
WebkitBoxOrient: 'vertical',
WebkitLineClamp: props.lineClamp,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add lineClamp as part of the props destructure above?

Copy link
Author

Choose a reason for hiding this comment

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

Done 👍

import { IndexableDocument } from '@backstage/plugin-search-common';
import { EntityRefLink } from '@backstage/plugin-catalog-react';

export interface GithubDiscussionsDocument extends IndexableDocument {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious about using IndexableDocument vs SearchDocument as per the documentation's comment about:

IndexableDocument is only useful for backends working directly with documents being inserted or retrieved from search indexes. When dealing with documents in the frontend, use SearchDocument

Copy link

Choose a reason for hiding this comment

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

That's a good catch; we should use SearchDocument.

Copy link
Author

Choose a reason for hiding this comment

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

Pushed the changes to use SearchDocument and also made the changes in my PR in community-plugins (see commit). So once that gets merged and the packages get published we'll be able to import the interface directly from the common package.

@MonicaG
Copy link
Contributor

MonicaG commented Nov 29, 2024

yarn why @guidanti/backstage-github-discussions-fetcher

@minkimcello - Here are the results:

yarn why @guidanti/backstage-github-discussions-fetcher                                                                                            ⬡ 20.18.1 [±DEVXT-1941 ●(✹)]
yarn why v1.22.19
[1/4] 🤔  Why do we have the module "@guidanti/backstage-github-discussions-fetcher"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "@guidanti/[email protected]"
info Reasons this module exists
   - "_project_#backend#@backstage-community#plugin-search-backend-module-github-discussions" depends on it
   - Hoisted from "_project_#backend#@backstage-community#plugin-search-backend-module-github-discussions#@guidanti#backstage-github-discussions-fetcher"
info Disk size without dependencies: "148KB"
info Disk size with unique dependencies: "49.51MB"
info Disk size with transitive dependencies: "148KB"
info Number of shared dependencies: 249
✨  Done in 0.83s.

@minkimcello
Copy link
Author

yarn why @guidanti/backstage-github-discussions-fetcher

@minkimcello - Here are the results:

yarn why @guidanti/backstage-github-discussions-fetcher                                                                                            ⬡ 20.18.1 [±DEVXT-1941 ●(✹)]
yarn why v1.22.19
[1/4] 🤔  Why do we have the module "@guidanti/backstage-github-discussions-fetcher"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "@guidanti/[email protected]"
info Reasons this module exists
   - "_project_#backend#@backstage-community#plugin-search-backend-module-github-discussions" depends on it
   - Hoisted from "_project_#backend#@backstage-community#plugin-search-backend-module-github-discussions#@guidanti#backstage-github-discussions-fetcher"
info Disk size without dependencies: "148KB"
info Disk size with unique dependencies: "49.51MB"
info Disk size with transitive dependencies: "148KB"
info Number of shared dependencies: 249
✨  Done in 0.83s.

Hmmm that's weird. Because @guidanti/[email protected] has [email protected] which has [email protected] as a dependency.

Could you try running yarn why for github-discussions-fetcher and pretty-ms and see which versions you get?

@MonicaG
Copy link
Contributor

MonicaG commented Nov 29, 2024

@minkimcello - here are the results for github-discussions-fetcher and pretty-ms:

> $ yarn why github-discussions-fetcher                                                                                                                ⬡ 20.18.1 [±DEVXT-1941 ●(✹)]
yarn why v1.22.19
[1/4] 🤔  Why do we have the module "github-discussions-fetcher"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "[email protected]"
info Reasons this module exists
   - "_project_#backend#@backstage-community#plugin-search-backend-module-github-discussions#@guidanti#backstage-github-discussions-fetcher" depends on it
   - Hoisted from "_project_#backend#@backstage-community#plugin-search-backend-module-github-discussions#@guidanti#backstage-github-discussions-fetcher#github-discussions-fetcher"
info Disk size without dependencies: "48.25MB"
info Disk size with unique dependencies: "120.27MB"
info Disk size with transitive dependencies: "48.25MB"
info Number of shared dependencies: 255
✨  Done in 0.84s.
> $ yarn why pretty-ms                                                                                                                                 ⬡ 20.18.1 [±DEVXT-1941 ●(✹)]
yarn why v1.22.19
[1/4] 🤔  Why do we have the module "pretty-ms"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "[email protected]"
info Reasons this module exists
   - "_project_#backend#@backstage-community#plugin-search-backend-module-github-discussions#@guidanti#backstage-github-discussions-fetcher#github-discussions-fetcher" depends on it
   - Hoisted from "_project_#backend#@backstage-community#plugin-search-backend-module-github-discussions#@guidanti#backstage-github-discussions-fetcher#github-discussions-fetcher#pretty-ms"
info Disk size without dependencies: "24KB"
info Disk size with unique dependencies: "44KB"
info Disk size with transitive dependencies: "44KB"
info Number of shared dependencies: 1
✨  Done in 0.68s.

@minkimcello
Copy link
Author

@MonicaG Oh oops, it wasn't complaining that the dependency was missing. Sorry about that. I should've looked at the error message more closely. Let me take a closer look and get back to you.

@MonicaG
Copy link
Contributor

MonicaG commented Nov 29, 2024

@MonicaG Oh oops, it wasn't complaining that the dependency was missing. Sorry about that. I should've looked at the error message more closely. Let me take a closer look and get back to you.

@minkimcello - Ok, thank you! No rush, as I'm OOO for the afternoon.

@MonicaG
Copy link
Contributor

MonicaG commented Dec 5, 2024

Hi, I am seeing the following message when running locally:

search info Operation[Discussions] failed, will retry in 364ms. documentType=github-discussions

I don't see any success messages for the operation. Should I?

Here are all the log messages I see w.r.t GitHub-discussions

[1] 2024-12-05T19:24:55.374Z search info Added GithubDiscussionsCollatorFactory collator factory for type github-discussions
[1] 2024-12-05T19:24:57.355Z search info Task worker starting: search_index_github_discussions, {"version":2,"cadence":"PT45M","initialDelayDuration":"PT10S","timeoutAfterDuration":"PT30M"} task=search_index_github_discussions
[1] 2024-12-05T19:38:57.455Z search warn Task timed out and was lost: search_index_github_discussions
[1] 2024-12-05T19:38:58.491Z search info Collating documents for github-discussions via GithubDiscussionsCollatorFactory documentType=github-discussions
[1] 2024-12-05T19:38:58.798Z search info Operation[Discussions] failed, will retry in 364ms. documentType=github-discussions
[1] 2024-12-05T19:38:59.292Z search info Operation[Discussions] failed, will retry in 959ms. documentType=github-discussions
[1] 2024-12-05T19:39:00.373Z search info Operation[Discussions] failed, will retry in 1.3s. documentType=github-discussions
[1] 2024-12-05T19:39:01.824Z search info Operation[Discussions] failed, will retry in 3s. documentType=github-discussions
[1] 2024-12-05T19:39:05.026Z search info Operation[Discussions] failed, will retry in 7.5s. documentType=github-discussions
[1] 2024-12-05T19:39:12.902Z search info Operation[Discussions] failed, will retry in 12.6s. documentType=github-discussions
[1] 2024-12-05T19:39:25.857Z search info Operation[Discussions] failed, will retry in 18s. documentType=github-discussions
[1] 2024-12-05T19:39:44.278Z search info Operation[Discussions] failed, will retry in 55.3s. documentType=github-discussions
[1] 2024-12-05T19:40:39.959Z search info Operation[Discussions] failed, will retry in 1m 40s. documentType=github-discussions
[1] 2024-12-05T19:42:20.287Z search info Operation[Discussions] failed, will retry in 2m 9.3s. documentType=github-discussions
[1] 2024-12-05T19:44:29.995Z search info Operation[Discussions] failed, will retry in 5m 17.4s. documentType=github-discussions

My app-config.yaml has the following configuration

search:
  collators:
    githubDiscussions:
      url: https://github.com/guidanti/github-discussions-fetcher

Also, do you have suggested search phrase(s) for the discussions on https://github.com/guidanti/github-discussions-fetcher that I could use for testing? Thanks!

@MonicaG
Copy link
Contributor

MonicaG commented Dec 5, 2024

I let it run for awhile, and it looked like it succeeded after some errors? However, I don't see any search results from the GitHub discussions board when I search for the word "Interactive". I was trying to get this discussion.

Here are the logs:

[1] 2024-12-05T20:09:58.068Z search warn Task timed out and was lost: search_index_github_discussions
[1] 2024-12-05T20:09:59.436Z search info Collating documents for github-discussions via GithubDiscussionsCollatorFactory documentType=github-discussions
[1] 2024-12-05T20:09:59.762Z search info Operation[Discussions] failed, will retry in 481ms. documentType=github-discussions
[1] 2024-12-05T20:10:00.365Z search info Operation[Discussions] failed, will retry in 874ms. documentType=github-discussions
[1] 2024-12-05T20:10:01.381Z search info Operation[Discussions] failed, will retry in 1.6s. documentType=github-discussions
[1] 2024-12-05T20:10:03.160Z search info Operation[Discussions] failed, will retry in 3.8s. documentType=github-discussions
[1] 2024-12-05T20:10:07.109Z search info Operation[Discussions] failed, will retry in 7s. documentType=github-discussions
[1] 2024-12-05T20:10:14.427Z search info Operation[Discussions] failed, will retry in 10.2s. documentType=github-discussions
[1] 2024-12-05T20:10:24.972Z search info Operation[Discussions] failed, will retry in 28.7s. documentType=github-discussions
[1] 2024-12-05T20:10:54.026Z search info Operation[Discussions] failed, will retry in 49.4s. documentType=github-discussions
[1] 2024-12-05T20:11:43.765Z search info Operation[Discussions] failed, will retry in 1m 17.5s. documentType=github-discussions
[1] 2024-12-05T20:13:01.691Z search info Operation[Discussions] failed, will retry in 2m 11.6s. documentType=github-discussions
[1] 2024-12-05T20:15:13.707Z search info Operation[Discussions] failed, will retry in 4m 26.9s. documentType=github-discussions
[1] 2024-12-05T20:19:40.891Z search info Operation[Discussions] failed, will retry in 9m 5.5s. documentType=github-discussions
[1] 2024-12-05T20:28:46.647Z search info Operation[Discussions] failed, will retry in 31m 58.3s. documentType=github-discussions
[1] 2024-12-05T20:39:59.423Z search info Operation[Discussions] timedout after 13 documentType=github-discussions
[1] 2024-12-05T20:39:59.430Z search info AssertionError: Could not fetch data from GraphQL API documentType=github-discussions
[1] 2024-12-05T20:39:59.435Z search error Encountered an error while ingesting GitHub Discussions Could not fetch data from GraphQL API documentType=github-discussions name=AssertionError stack=AssertionError: Could not fetch data from GraphQL API
[1] at assert (/Users/mgranboi/development/developer-portal/node_modules/github-discussions-fetcher/src/deps/jsr.io/@std/assert/1.0.3/assert.ts:21:11)
[1] at query (/Users/mgranboi/development/developer-portal/node_modules/github-discussions-fetcher/src/lib/useGraphQL.ts:145:13)
[1] at fetchDiscussions (/Users/mgranboi/development/developer-portal/node_modules/github-discussions-fetcher/src/fetchers/discussion.ts:43:25)
[1] at fetchGithubDiscussions (/Users/mgranboi/development/developer-portal/node_modules/github-discussions-fetcher/src/fetchGithubDiscussions.ts:55:63)
[1] at (/Users/mgranboi/development/developer-portal/node_modules/@guidanti/backstage-github-discussions-fetcher/src/lib/fetchDiscussionDocuments.ts:22:38)
[1] 2024-12-05T20:39:59.435Z search info Collator indexed 0 documents documentType=github-discussions
[1] 2024-12-05T20:39:59.435Z search warn Index for github-discussions was not replaced: indexer received 0 documents documentType=github-discussions
[1] 2024-12-05T20:39:59.436Z search info Collating documents for github-discussions succeeded documentType=github-discussions
[1] 2024-12-05T20:40:04.454Z search info Collating documents for github-discussions via GithubDiscussionsCollatorFactory documentType=github-discussions
[1] 2024-12-05T20:40:04.746Z search info Operation[Discussions] failed, will retry in 365ms. documentType=github-discussions
[1] 2024-12-05T20:40:05.236Z search info Operation[Discussions] failed, will retry in 796ms. documentType=github-discussions
[1] 2024-12-05T20:40:06.142Z search info Operation[Discussions] failed, will retry in 1.2s. documentType=github-discussions
[1] 2024-12-05T20:40:07.504Z search info Operation[Discussions] failed, will retry in 2.6s. documentType=github-discussions
[1] 2024-12-05T20:40:10.290Z search info Operation[Discussions] failed, will retry in 4.7s. documentType=github-discussions
[1] 2024-12-05T20:40:15.362Z search info Operation[Discussions] failed, will retry in 8.2s. documentType=github-discussions
[1] 2024-12-05T20:40:23.968Z search info Operation[Discussions] failed, will retry in 29.6s. documentType=github-discussions
[1] 2024-12-05T20:40:53.976Z search info Operation[Discussions] failed, will retry in 53.6s. documentType=github-discussions
[1] 2024-12-05T20:41:47.862Z search info Operation[Discussions] failed, will retry in 2m 2.8s. documentType=github-discussions
[1] 2024-12-05T20:43:51.043Z search info Operation[Discussions] failed, will retry in 3m 3.5s. documentType=github-discussions
[1] 2024-12-05T20:46:54.864Z search info Operation[Discussions] failed, will retry in 5m 30.3s. documentType=github-discussions
[1] 2024-12-05T20:52:25.754Z search info Operation[Discussions] failed, will retry in 14m 8.7s. documentType=github-discussions
[1] 2024-12-05T21:06:34.768Z search info Operation[Discussions] failed, will retry in 27m 34s. documentType=github-discussions
[1] 2024-12-05T21:10:04.468Z search info Operation[Discussions] timedout after 13 documentType=github-discussions
[1] 2024-12-05T21:10:04.480Z search info AssertionError: Could not fetch data from GraphQL API documentType=github-discussions
[1] 2024-12-05T21:10:04.483Z search error Encountered an error while ingesting GitHub Discussions Could not fetch data from GraphQL API documentType=github-discussions name=AssertionError stack=AssertionError: Could not fetch data from GraphQL API
[1] at assert (/Users/mgranboi/development/developer-portal/node_modules/github-discussions-fetcher/src/deps/jsr.io/@std/assert/1.0.3/assert.ts:21:11)
[1] at query (/Users/mgranboi/development/developer-portal/node_modules/github-discussions-fetcher/src/lib/useGraphQL.ts:145:13)
[1] at fetchDiscussions (/Users/mgranboi/development/developer-portal/node_modules/github-discussions-fetcher/src/fetchers/discussion.ts:43:25)
[1] at fetchGithubDiscussions (/Users/mgranboi/development/developer-portal/node_modules/github-discussions-fetcher/src/fetchGithubDiscussions.ts:55:63)
[1] at (/Users/mgranboi/development/developer-portal/node_modules/@guidanti/backstage-github-discussions-fetcher/src/lib/fetchDiscussionDocuments.ts:22:38)
[1] 2024-12-05T21:10:04.484Z search info Collator indexed 0 documents documentType=github-discussions
[1] 2024-12-05T21:10:04.484Z search warn Index for github-discussions was not replaced: indexer received 0 documents documentType=github-discussions
[1] 2024-12-05T21:10:04.487Z search info Collating documents for github-discussions succeeded documentType=github-discussions

@MonicaG
Copy link
Contributor

MonicaG commented Dec 6, 2024

It works for @oomIRL locally. I'll try deleting my node_modules directory and see if that fixes the issue

@minkimcello
Copy link
Author

@MonicaG

search info Operation[Discussions] failed, will retry in 364ms. documentType=github-discussions

I don't see any success messages for the operation. Should I?

You'll see that error message whenever the fetch operation fails. It's an error message we're surfacing intentionally. GitHub's GraphQL API, in my experience, is not very reliable/consistent. If you make these fetch requests on weekends when their traffic is lower, it's much more likely that it'll fetch successfully.

One way you can make it successfully fetch more reliably is by adjusting the request batch size:

search:
  collators:
    githubDiscussions:
      // ...
+      discussionsBatchSize: 75
+      commentsBatchSize: 75
+      repliesBatchSize: 75
    # these are all 100 by default
    # 100 is the highest GitHub lets you query

But depending on how many discussions/comments/replies you have (in the future), you might end up getting rate-limited. The rate cost are not proportional to the batch size so it can balloon up easily.

We demo'd with vercel/next.js discussions where they have tens of thousands of discussions and hundreds of thousands of comments. Depending on how you configure these batch size numbers, the points required varied from something like 500 points to +20,000 (out of the 5,000 available per hour).

@minkimcello
Copy link
Author

However, I don't see any search results from the GitHub discussions board when I search for the word "Interactive". I was trying to get guidanti/github-discussions-fetcher#48.

When I search interactive, I see the following results:

Can you run the portal with the stackoverflow collator disabled so that you can verify that you're ingesting discussion documents?

@MonicaG
Copy link
Contributor

MonicaG commented Dec 9, 2024

HI @minkimcello - Sorry for the delay in my response. It is working. The error was on my part, I forgot to unpack the tar file.

Regarding the API: I assume the discussions plugin works whether a GitHub PAT or a GitHub App is used. But I wanted to confirm with you. Do we need to enable any permissions in the GitHub App for discussions access?

Locally, we use a GitHub PAT, but our deployment uses a GitHub App installed on the org.

app-config.local.yaml file setting:

integrations:
  github:
    - host: github.com
      token: ${GITHUB_TOKEN}

app-config.production.yaml file settings:

integrations:
  github:
    - host: github.com
       apps:
         - $include: /path/to/github-app.yml

@minkimcello
Copy link
Author

HI @minkimcello - Sorry for the delay in my response. It is working. The error was on my part, I forgot to unpack the tar file.

Huh? Did you mean you forgot to pull the latest commit? You shouldn't have to unpack it yourself. (At least I don't think).

Regarding the API: I assume the discussions plugin works whether a GitHub PAT or a GitHub App is used.

Yes. It'll use whatever is configured under integrations.github with the host of github.com.

But I wanted to confirm with you. Do we need to enable any permissions in the GitHub App for discussions access?

We've only tested it with public repositories in which case you shouldn't technically have to enable any permissions because PATs have read-access to public repos by default. But for non-public repositories, you need to toggle on discussions when you generate your token.

Same goes for GitHub apps, you need to ensure discussions is enabled in repository permissions.

@MonicaG
Copy link
Contributor

MonicaG commented Dec 9, 2024

Hi @minkimcello - I have the latest commit of 2221270. I think the issue was my GITHUB_TOKEN. I unpacked the tar file and regenerated my GITHUB_TOKEN (it was not expired) as I was just trying to get things to work. @oomIRL reported that he unpacked the tar file and it worked for him. I ran the site locally with both changes and it worked. I assumed it was the unpacking that worked.

However, I have since removed the artifacts from the unpacking, ran it again, and it works.

All this to say, I think it was something on my end that wasn't working. It now works.

Thank you for your answers about the API. Sounds good.

@MonicaG
Copy link
Contributor

MonicaG commented Dec 9, 2024

@minkimcello @taras. I've run it locally, and it looks good to me. Thank you!

There is one outstanding conversation. Other than that, I am done with my review.

@oomIRL is reviewing as well and may have some comments.

Thanks again!

@oomIRL
Copy link
Contributor

oomIRL commented Dec 12, 2024

@minkimcello I've spent some time testing these changes locally and everything has been working really well.

There is one very minor change I would like to see. I was experimenting with adding a GitHub icon prop, and I think the consistency with other search results could be improved.

For example:
image

I tried changing GithubDiscussionsSearchResultListItem to use ListItem and a Divider element:

  return (
    <>
      <ListItem alignItems='center'>
        {icon && <ListItemIcon>{icon}</ListItemIcon>}
           {...}
      </ListItem>
      
      <Divider />
    </>
  );
image

Thoughts, comments?
Thanks!

@minkimcello
Copy link
Author

@oomIRL I matched the UI component to be consistent with the stackoverflow list item:

Screenshot 2024-12-13 at 4 12 02 PM

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