Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go/tools/gopackagesdriver/bazel_json_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (b *BazelJSONBuilder) adjustToRelativePathIfPossible(request string) string

func (b *BazelJSONBuilder) packageQuery(importPath string) string {
if strings.HasSuffix(importPath, "/...") {
importPath = fmt.Sprintf(`^%s(/.+)?$`, strings.TrimSuffix(importPath, "/..."))
importPath = fmt.Sprintf(`%s(/.+)?$`, strings.TrimSuffix(importPath, "/..."))
Copy link
Author

Choose a reason for hiding this comment

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

The pattern supplied being treated as a regular expression can result in different behaviour if the input happens to contain regexp special characters. Leaving it as is here

Copy link
Member

Choose a reason for hiding this comment

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

If we change this, let's fix that as well. Could you wrap the import path into regexp.QuoteMeta?

Copy link
Author

Choose a reason for hiding this comment

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

I pushed a commit that escapes both the wild card case and the default case: 23be4f0

But this essentially means that the ./something query won't work at least against the path that we are seeing //something as \./something won't match //something. I'm unsure if this is correct, and/or if the //something paths are only specific to our implementation.

Copy link
Author

@Aaronkala Aaronkala Mar 7, 2025

Choose a reason for hiding this comment

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

Okay the importpaths it's actually matching against are in the form of github.com/orgname/reponame/something/foo/bar as defined in go_library() importpath

I'll test if importpath_aliases aliases fixes this for us with something like ./something/foo/bar as the alias

Copy link
Author

Choose a reason for hiding this comment

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

Hmm but the query is targetting only importpath 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Sorry for getting back to this so late, where are we at? Should I take another look?

}

return fmt.Sprintf(
Expand Down