Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Fix CommitSigningConfiguration resolver err#52965

Merged
courier-new merged 3 commits into
kr/ux-create-appfrom
becca/CommitSigningConfiguration-resolver-dont-err-on-init-state
Jun 6, 2023
Merged

Fix CommitSigningConfiguration resolver err#52965
courier-new merged 3 commits into
kr/ux-create-appfrom
becca/CommitSigningConfiguration-resolver-dont-err-on-init-state

Conversation

@st0nebreaker

@st0nebreaker st0nebreaker commented Jun 5, 2023

Copy link
Copy Markdown
Contributor

Fixes github_apps store resolver to not error if an app is not found. Adds ErrNoGitHubAppFound type assertion to create a generic error type to re-use for any github_app that can't be found

Partial pair with @courier-new the great 👑

Before
image

After
image

Test plan

  • Updated test
  • Buildkite
  • Run locally, ensure /site-admin/batch-changes route doesn't error on initial state (when you haven't configured any github_apps yet)

@cla-bot cla-bot Bot added the cla-signed label Jun 5, 2023
@st0nebreaker st0nebreaker marked this pull request as ready for review June 6, 2023 00:17
@st0nebreaker st0nebreaker requested review from a team and courier-new June 6, 2023 00:17
@sourcegraph-bot

Copy link
Copy Markdown
Contributor

📖 Storybook live preview

@courier-new courier-new left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank youuuu! This is a huge help.

Comment thread enterprise/internal/github_apps/store/store_test.go
@courier-new courier-new merged commit ae194d0 into kr/ux-create-app Jun 6, 2023
@courier-new courier-new deleted the becca/CommitSigningConfiguration-resolver-dont-err-on-init-state branch June 6, 2023 01:16
return nil, ErrNoGitHubAppFound{Criteria: strWhere}
swhere := where.Query(sqlf.PostgresBindVar)
for i, arg := range where.Args() {
swhere = strings.Replace(swhere, fmt.Sprintf("$%d", i+1), fmt.Sprintf("%v", arg), 1)

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.

What are you replacing here exactly @courier-new ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Apparently swhere := where.Query(sqlf.PostgresBindVar) only binds the variables, but not their values. So if you logged the error message, it'd look like:

no app exists matching criteria: 'domain = $1 AND base_url = $2'

which is helpful but obviously still not quite what we were going for. 😅 I couldn't seem to find a sqlf.Query method that did this automatically, since normally it happens at DB Query time based on the DB context, but I did find a handful of other places in the code where we build the full string with values by iterating over the sqlf.Query.Args() and strings.Replace()-ing them at their indices in the original string, so that's what I decided to do here, too. 🙂

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 see, I see. Thanks for catching this! 🙏🏻

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants