Skip to content

Only assign plugin path if set in config#1893

Merged
bufdev merged 2 commits intomainfrom
pkw/issue-1850-bufgen-v1beta1-path
Mar 7, 2023
Merged

Only assign plugin path if set in config#1893
bufdev merged 2 commits intomainfrom
pkw/issue-1850-bufgen-v1beta1-path

Conversation

@pkwarren
Copy link
Member

@pkwarren pkwarren commented Mar 7, 2023

When migrating a v1beta1 external config to a plugin config, we should only set the new path slice if the path in the config is non-empty. Otherwise, we'll try to exec an empty command by initializing the slice to {""}.

Fixes #1850.

When migrating a v1beta1 external config to a plugin config, we should
only set the new path slice if the path in the config is non-empty.
Otherwise, we'll try to exec an empty command by initializing the slice
to {""}.
@pkwarren pkwarren requested review from bufdev and tonyli233 March 7, 2023 15:40
Strategy: strategy,
}
if plugin.Path != "" {
pluginConfig.Path = []string{plugin.Path}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the fix.

config, err = ReadConfig(ctx, nopLogger, provider, readBucket, ReadConfigWithOverride(string(data)))
require.NoError(t, err)
require.Equal(t, successConfig3, config)
testReadConfigSuccess := func(t *testing.T, configPath string, expected *Config) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Refactored some duplicated code into a common function.

plugins:
- name: go
out: gen/go
strategy: all
Copy link
Member Author

Choose a reason for hiding this comment

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

Sample config without a path specified so we can verify the fix.

@bufdev bufdev merged commit a14e311 into main Mar 7, 2023
@bufdev bufdev deleted the pkw/issue-1850-bufgen-v1beta1-path branch March 7, 2023 16:04
@bufdev bufdev mentioned this pull request Mar 7, 2023
Monirul1 pushed a commit to Monirul1/buf that referenced this pull request Apr 30, 2023
When migrating a v1beta1 external config to a plugin config, we should
only set the new path slice if the path in the config is non-empty.
Otherwise, we'll try to exec an empty command by initializing the slice
to `{""}`.

Fixes bufbuild#1850.
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.

plugin not found in $PATH

3 participants