Skip to content

fix(app-connections): github app connection creation #4276

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

Merged
merged 1 commit into from
Jul 30, 2025

Conversation

DanielHougaard
Copy link
Member

Description 📣

This PR is a fix for creating/updating github app connections. It fails due to host being undefined, which is always the case when creating app connections without a custom github instance.

image

Type ✨

  • Bug fix
  • New feature
  • Improvement
  • Breaking change
  • Documentation

@DanielHougaard DanielHougaard self-assigned this Jul 30, 2025
@DanielHougaard DanielHougaard requested a review from x032205 July 30, 2025 17:05
@maidul98
Copy link
Collaborator

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR fixes a bug in GitHub app connection creation where undefined host values were causing connection failures. The fix implements conditional object spreading using the pattern ...(credentials?.host && { host: credentials.host }) to only include the host field when it has a truthy value.

The changes are applied to four locations in the GitHub OAuth callback handler:

  • Two update operations (with and without installationId)
  • Two create operations (for App and OAuth methods)

This addresses the common scenario where users connect to the default GitHub instance (github.com) rather than a custom GitHub Enterprise instance. In these cases, credentials.host would be undefined, but the previous code was always including it in the API request payload, which likely caused validation errors on the backend.

The fix ensures that standard GitHub connections omit the host field entirely, while GitHub Enterprise connections with custom hostnames still include the host field as expected. This maintains backward compatibility while resolving the connection creation failures.

Confidence score: 4/5

• This is a safe bug fix that resolves a clear functional issue with GitHub app connections
• The conditional spread syntax is a standard JavaScript pattern that properly handles undefined values
• The fix is applied consistently across all relevant code paths (update/create operations for both OAuth and App methods)

1 file reviewed, no comments

Edit Code Review Bot Settings | Greptile

@DanielHougaard DanielHougaard merged commit 0926950 into main Jul 30, 2025
6 checks passed
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