Skip to content
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

[Heartbeat] Fix broken invocation of synth package #26228

Merged
merged 2 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions x-pack/heartbeat/monitors/browser/source/validatepackage.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ func validatePackageJSON(path string) error {
if synthVersion == "" {
synthVersion = pkgJson.DevDependencies.SynthVersion
}

if strings.HasPrefix(synthVersion, "file://") {
return nil
}

err = validateVersion(ExpectedSynthVersion, synthVersion)
if err != nil {
return fmt.Errorf("could not validate @elastic/synthetics version: '%s' %w", synthVersion, err)
Expand Down
2 changes: 1 addition & 1 deletion x-pack/heartbeat/monitors/browser/synthexec/synthexec.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const debugSelector = "synthexec"
func SuiteJob(ctx context.Context, suitePath string, params common.MapStr, extraArgs ...string) (jobs.Job, error) {
// Run the command in the given suitePath, use '.' as the first arg since the command runs
// in the correct dir
newCmd, err := suiteCommandFactory(suitePath, append(extraArgs, ".")...)
newCmd, err := suiteCommandFactory(suitePath, append([]string{suitePath}, extraArgs...)...)
Copy link
Member

Choose a reason for hiding this comment

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

is this a bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's intentional and fixes the bug.

Sorry, will add tests soon, I shouldn't have flagged you for review this early. The bug was we'd invoke with --capabilities foo bar . where . indicated the current directory. Synthetics interpreted . as a capability, not the location of the test. So, we needed to ensure that the suite path was the first arg. While I was at it I switched from . to suitePath which was more readable and makes copy/pasting the command easier.

Copy link
Member

Choose a reason for hiding this comment

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

Totally, no worries. Yes this is the issue with varidiac args in the commander library we are using - This is one of the reason why I was suggesting to add a test here - #25808 (comment)

Glad we caught the error. If you are curios - https://github.com/tj/commander.js/blob/master/docs/options-taking-varying-arguments.md

if err != nil {
return nil, err
}
Expand Down