Skip to content

Export ToBoolPtr and RequiredParam #495

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 3 commits into from
Jun 9, 2025
Merged

Conversation

LuluBeatson
Copy link
Contributor

  1. Export ToBoolPtr and RequiredParam functions from the github package.
  2. Clean up the type assertion in RequiredParam

@LuluBeatson LuluBeatson changed the title Lulu/export-utils Export ToBoolPtr and RequiredParam Jun 9, 2025
@LuluBeatson LuluBeatson marked this pull request as ready for review June 9, 2025 13:02
@Copilot Copilot AI review requested due to automatic review settings June 9, 2025 13:02
@LuluBeatson LuluBeatson requested a review from a team as a code owner June 9, 2025 13:02
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR makes the ToBoolPtr and RequiredParam helpers public and updates all call sites to use the exported versions, while simplifying the type assertion in RequiredParam.

  • Export ToBoolPtr and replace all uses of toBoolPtr
  • Export RequiredParam and update call sites, eliminating redundant lookups
  • Adjust documentation comment for ToBoolPtr

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/github/tools.go Renamed toBoolPtr to ToBoolPtr with doc comment
pkg/github/server_test.go Updated test to use RequiredParam[string]
pkg/github/server.go Renamed requiredParam to RequiredParam, cleaned up assertions
pkg/github/secret_scanning.go Swapped toBoolPtr for ToBoolPtr, updated requiredParam calls
pkg/github/search.go Swapped toBoolPtr for ToBoolPtr, updated requiredParam calls
pkg/github/repositories.go Swapped toBoolPtr for ToBoolPtr, updated requiredParam calls
pkg/github/pullrequests.go Swapped toBoolPtr for ToBoolPtr, updated requiredParam calls
pkg/github/notifications.go Swapped toBoolPtr for ToBoolPtr, updated requiredParam calls
pkg/github/issues.go Swapped toBoolPtr for ToBoolPtr, updated requiredParam calls
pkg/github/dynamic_tools.go Swapped toBoolPtr for ToBoolPtr, updated requiredParam calls
pkg/github/context_tools.go Swapped toBoolPtr for ToBoolPtr
pkg/github/code_scanning.go Swapped toBoolPtr for ToBoolPtr, updated requiredParam calls
Comments suppressed due to low confidence (2)

pkg/github/tools.go:148

  • Consider adding a unit test for ToBoolPtr to verify it returns a non-nil pointer whose dereferenced value matches the input.
func ToBoolPtr(b bool) *bool {

pkg/github/server.go:79

  • Enhance this error message by including the actual value or type encountered (e.g., use %T with the actual argument) to aid debugging.
return zero, fmt.Errorf("parameter %s is not of type %T", p, zero)

@SamMorrowDrums SamMorrowDrums merged commit cbcf29f into main Jun 9, 2025
16 checks passed
@SamMorrowDrums SamMorrowDrums deleted the lulu/export-utils branch June 9, 2025 13:11
@williammartin
Copy link
Collaborator

Just a couple of notes on this @LuluBeatson @SamMorrowDrums

I didn't export toBoolPtr because github.ToBoolPtr is pretty janky. It's not a meaningful abstraction. It would likely be better for us to expose a ghmcp.Annotations which uses types we care about and has a single adapter into the mcp server types.

Secondly, I strongly encourage avoiding use of all the param parsing functions from this package. The jsonschema should be the source of truth. Using these takes the implementation away from where we should want it to go IMO.

That said, it's not like it's a huge cost to exporting and using these compared to where we are today. I just wanted to let you know my thinking on this.

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