Repository navigation
Fix URL templates with text after the URLJoinPath block - #59
Open
mateusz-kolecki wants to merge 1 commit into
Open
mateusz-kolecki wants to merge 1 commit into
mateusz-kolecki wants to merge 1 commit into
Conversation
Zoekt's Bitbucket Server file template is
{{URLJoinPath "<repo-url>/browse" .Path}}?at={{.Version}}
The regex that recognizes URLJoinPath templates anchored the closing }}
to the end of the string, so the lazy args group ran up to the final }}
and the token `.Path}}?at={{.Version` reached JSON.parse. Every search
whose results included a file from a Bitbucket Server repository then
failed with "zoekt call failed: SyntaxError: Unexpected token '.'".
Capture whatever follows the URLJoinPath block as a suffix, evaluate
{{.Version}} and {{.Path}} in it as single URL components, and append it
to the joined path for both file and commit templates.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
With a Zoekt index that contains repositories mirrored from Bitbucket Server, every search whose results include a file from one of those repositories fails:
Reproduced with neogrok v1.2.6 and Zoekt built from b55ce727df8cfbed76b8a1420445fd0cf93f3256 against Bitbucket Server 9.6.2.
Cause
Zoekt's Bitbucket Server file URL template puts the version in a query string after the
URLJoinPathblock:urlJoinPathTemplateinsrc/lib/url-templates.tsanchors the closing}}to the end of the string, so the lazyargsgroup runs all the way to the final}}. The last whitespace-split token is then.Path}}?at={{.Version, which is neither.Versionnor.Path, so it is handed toJSON.parseas if it were a quoted string.Fix
URLJoinPathblock in asuffixgroup.{{.Version}}and{{.Path}}inside the suffix withencodeURIComponent, since there they are single URL components (query values) rather than path segments.evaluateFileUrlTemplateandevaluateCommitUrlTemplate. Templates without a suffix behave exactly as before.refs/heads/...version.yarn run lintandyarn run testpass locally. With this change the failing search renders Bitbucket Server links such as.../browse/Dockerfile?at=<sha>correctly.🤖 Generated with Claude Code