Skip to content

implement change provider - github#98

Closed
rashmi-prithyani wants to merge 6 commits into
mainfrom
rprithyani/implementGithubChangeProvider
Closed

implement change provider - github#98
rashmi-prithyani wants to merge 6 commits into
mainfrom
rprithyani/implementGithubChangeProvider

Conversation

@rashmi-prithyani
Copy link
Copy Markdown
Contributor

@rashmi-prithyani rashmi-prithyani commented Feb 27, 2026

Summary

implements change provider - github

  • Fetches PR metadata including changed files, patches, line counts, and author
    information
  • Supports stacked PRs (multiple PRs in a single request)
  • Handles pagination for PRs with >100 files
  • Validates PR staleness by comparing head SHA with submitted SHA
  • Validates stack consistency (same provider, org, and repo)
  • Partial success support: continues fetching if individual PRs fail

Test Plan

CI and tests

Issues

@rashmi-prithyani rashmi-prithyani marked this pull request as ready for review February 27, 2026 05:25
Comment thread extension/changeprovider/change_provider.go Outdated
Comment on lines +23 to +25
// GraphQLURL is the GitHub GraphQL API endpoint
// (e.g., "https://api.github.com/graphql" or "https://ghe.example.com/api/graphql").
GraphQLURL string
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i think we don't need it, HTTPClient should encapsulate it

Comment thread extension/changeprovider/github/provider.go Outdated
Comment thread extension/changeprovider/github/validate.go Outdated
Comment thread extension/changeprovider/github/validate.go Outdated
Comment thread extension/changeprovider/github/provider.go Outdated
Comment thread extension/changeprovider/github/provider.go Outdated
@rashmi-prithyani rashmi-prithyani force-pushed the rprithyani/implementGithubChangeProvider branch from 9507bc0 to a3b5ed8 Compare March 3, 2026 07:39
@rashmi-prithyani rashmi-prithyani changed the title implement change provider - github [WIP]implement change provider - github Mar 3, 2026
Comment thread extension/changeprovider/github/provider.go Outdated
Comment on lines +37 to +43
if httpClient == nil {
timeout := config.Timeout
if timeout <= 0 {
timeout = DefaultTimeout
}
httpClient = createDefaultClient(config.Token, timeout)
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why not just always required correct client from the caller?

)

// Config holds configuration for connecting to a GitHub backend.
type Config struct {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why do we need it? can we not make it part of caller responsibility? The problem i have with this is somewhat very dependent on how token is generated, so having it outside allows one to be flexible about it.

I could provide tokenProvider into oauth2 client which can create a httpclient that i can pass around without having to make provider be aware about how token is generated

@rashmi-prithyani rashmi-prithyani force-pushed the rprithyani/implementGithubChangeProvider branch 3 times, most recently from 2c5f9ff to b5cff4e Compare March 5, 2026 08:14
Comment thread extension/changeprovider/github/provider.go Outdated
Comment thread extension/changeprovider/github/provider.go Outdated
}).Counter("get_errors").Inc(1)
fetchErrors = append(fetchErrors, fmt.Errorf("PR #%d: %w", cid.PRNumber, err))
failedPRs = append(failedPRs, cid.PRNumber)
continue // Continue to next PR
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do we need to continue?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thought here is that if we fail to get change info for one of the PRs in a stack, we still continue to fetch changes for the other PRs in the stack.

Then this would be marked as a retryable error and we could attempt to fetch in next attempt. That's why added the continue. What do you think ?

Comment on lines +9 to +12
type Client struct {
httpClient *http.Client
baseURL string
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

any reason we need it? httpClient should be enough, it can have baseURL in it, i think we can get rid of config file completely.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I created this config file in response to this previous comment - #98 (comment)

If we are ok to pass in the base url as a param to provider struct, I can revert to the previous version. By itself I dont think the httpCleint has facility to configure a baseURL.

Comment thread extension/changeprovider/github/graphql.go Outdated
Comment thread extension/changeprovider/github/graphql.go Outdated
rashmi-prithyani and others added 5 commits March 12, 2026 05:36
- Rename ID to URI with full scheme://org/repo/pr/sha format
- Remove defensive checks and excessive logging
- Simplify validation utilities (pure functions)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace Params with Config to encapsulate BaseURL + Token + Timeout
together, addressing review feedback about HTTPClient encapsulation.

Changes:
- Add Config type with BaseURL, Token, Timeout, and optional HTTPClient
- Derive GraphQL URL from BaseURL (no separate parameter needed)
- Add configurable timeout (defaults to 30s)
- Simplify main.go to use DefaultConfig()
- Update all tests to use Config instead of Params

Benefits:
- Impossible to misconfigure (URL and auth bundled)
- Multi-instance support (github.com + GHE)
- Flexible timeout per instance
- Cleaner API surface

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace Config pattern with Client wrapper that encapsulates HTTP client
and GraphQL URL. Simplifies provider by giving caller full control over
authentication and endpoint configuration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rashmi-prithyani rashmi-prithyani force-pushed the rprithyani/implementGithubChangeProvider branch from b5cff4e to 5c812f8 Compare March 12, 2026 05:40
@rashmi-prithyani rashmi-prithyani changed the title [WIP]implement change provider - github implement change provider - github Mar 12, 2026
@rashmi-prithyani
Copy link
Copy Markdown
Contributor Author

Closing this one in favor of #141 which has cherry picked these changes and also addressed code review comments.

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