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

KV Import fails on Windows using Consul version 1.10.0 #10583

Closed
DDSGooch opened this issue Jul 9, 2021 · 1 comment · Fixed by #10820
Closed

KV Import fails on Windows using Consul version 1.10.0 #10583

DDSGooch opened this issue Jul 9, 2021 · 1 comment · Fixed by #10820
Assignees
Labels
theme/kv Issues related to the key value store type/bug Feature does not function as expected

Comments

@DDSGooch
Copy link

DDSGooch commented Jul 9, 2021

Summary

Consul KV import fails using version 1.10.0 when running under Windows.

This is due to the change made to this line:

Key: filepath.Join(c.prefix, entry.Key),

in this pull request: https://github.com/hashicorp/consul/pull/9792/files#diff-4b09e89bd0587b4486d7a8c6e36e86b4dbc1253737775c39e593ab09020ff3c7R82

Unfortunately this means that all keys are imported with backslashes (\) rather than forward slashes (/), as can be seen below.

Steps to Reproduce

With version 1.10.0 of consul:

  1. Create import file
[{"key": "prefix/KeyField1/KeyField2", "flags": 0, "value": "QmFja3VwXA==" }]
  1. Import the file with the command:
    consul kv import @consuldata.json
    which gives the following output
    Imported: prefix\KeyField1\KeyField2
  2. Export the data
    consul kv export
    which gives the following output
[
       {
                "key": "prefix\\KeyField1\\KeyField2",
                "flags": 0,
                "value": "QmFja3VwXA=="
        }
]

Expected Behaviour

With version 1.9.5 of consul:

  1. Create import file
[{"key": "prefix/KeyField1/KeyField2", "flags": 0, "value": "QmFja3VwXA==" }]
  1. Import the file with the command:
    consul kv import @consuldata.json
    which gives the following output
    Imported: prefix/KeyField1/KeyField2
  2. Export the data
    consul kv export
    which gives the following output
[
        {
                "key": "prefix/KeyField1/KeyField2",
                "flags": 0,
                "value": "QmFja3VwXA=="
        }
]
@dnephin
Copy link
Contributor

dnephin commented Jul 9, 2021

Thank you for reporting this issue and identifying the problem! I think that line you identified needs to change to use path.Join instead of filepath.Join.

@dnephin dnephin added theme/kv Issues related to the key value store type/bug Feature does not function as expected labels Jul 9, 2021
blake added a commit that referenced this issue Aug 10, 2021
Consul 1.10 (PR #9792) introduced the ability to specify a prefix when
importing KV's. This however introduced a regression on Windows
systems which breaks `kv import`. The key name is joined with
specified`-prefix` using `filepath.Join()` which uses a forward slash
(/) to delimit values on Unix-based systems, and a backslash (\) to
delimit values on Windows – the latter of which is incompatible with
Consul KV paths.

This commit replaces filepath.Join() with path.Join() which uses a
forward slash as the delimiter, providing consistent key join behavior
across supported operating systems.

Fixes #10583
@blake blake self-assigned this Aug 10, 2021
blake added a commit that referenced this issue Aug 10, 2021
Consul 1.10 (PR #9792) introduced the ability to specify a prefix when
importing KV's. This however introduced a regression on Windows
systems which breaks `kv import`. The key name is joined with
specified`-prefix` using `filepath.Join()` which uses a forward slash
(/) to delimit values on Unix-based systems, and a backslash (\) to
delimit values on Windows – the latter of which is incompatible with
Consul KV paths.

This commit replaces filepath.Join() with path.Join() which uses a
forward slash as the delimiter, providing consistent key join behavior
across supported operating systems.

Fixes #10583
hc-github-team-consul-core pushed a commit that referenced this issue Aug 10, 2021
Consul 1.10 (PR #9792) introduced the ability to specify a prefix when
importing KV's. This however introduced a regression on Windows
systems which breaks `kv import`. The key name is joined with
specified`-prefix` using `filepath.Join()` which uses a forward slash
(/) to delimit values on Unix-based systems, and a backslash (\) to
delimit values on Windows – the latter of which is incompatible with
Consul KV paths.

This commit replaces filepath.Join() with path.Join() which uses a
forward slash as the delimiter, providing consistent key join behavior
across supported operating systems.

Fixes #10583
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/kv Issues related to the key value store type/bug Feature does not function as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants