Cover resource_path and all occurrences in workspace prefix rewrite#5507
Open
simonfaltum wants to merge 1 commit into
Open
Cover resource_path and all occurrences in workspace prefix rewrite#5507simonfaltum wants to merge 1 commit into
simonfaltum wants to merge 1 commit into
Conversation
The legacy /Workspace prefix rewrite missed ${workspace.resource_path}, only fixed the first occurrence of the first matching pattern per string, and iterated patterns in nondeterministic map order.
Co-authored-by: Isaac
Contributor
Waiting for approvalBased on git history, these people are best suited to review:
Eligible reviewers: Suggestions based on git history. See OWNERS for ownership rules. |
Collaborator
|
Commit: ed0991f
22 interesting tests: 15 SKIP, 7 KNOWN
Top 29 slowest tests (at least 2 minutes):
|
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.
Why
Found during a full-repo review of the CLI. The
RewriteWorkspacePrefixmutator strips the legacy/Workspaceprefix from strings that reference${workspace.*}path variables, but it had three gaps:${workspace.resource_path}was missing from the rewrite table even thoughPrependWorkspacePrefixprefixes it, so a legacy/Workspace/${workspace.resource_path}reference silently interpolated to a doubled/Workspace/Workspace/...path.strings.Replace(..., 1)and returned on the first match, so only the first occurrence of the first matching pattern was fixed; any further occurrences in the same string stayed broken.Changes
Before, a string was rewritten once for one nondeterministically chosen pattern and
resource_pathreferences were never rewritten; now every occurrence of every known pattern, includingresource_path, is rewritten in a fixed order.In
bundle/config/mutator/rewrite_workspace_prefix.go:/Workspace/${workspace.resource_path}and/Workspace${workspace.resource_path}to the rewrite table, matching the path set handled byPrependWorkspacePrefix.strings.ReplaceAlland continue through all patterns instead of returning after the first match. One warning is emitted per matched pattern; strings with a single match produce exactly the same warning as before.Test plan
TestNoWorkspacePrefixUsedwithresource_pathcases (both slash and no-slash variants), a multi-occurrence string, and a string matching two different patterns; verified warnings and rewritten values.go test ./bundle/config/mutatorpasses../task fmt-q,./task lint-q(0 issues), and./task checkspass.This pull request and its description were written by Isaac.