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

Using gaiacli config node breaks ~/.gaiacli/config/config.toml #3899

Closed
4 tasks
mperklin opened this issue Mar 14, 2019 · 3 comments · Fixed by #3903
Closed
4 tasks

Using gaiacli config node breaks ~/.gaiacli/config/config.toml #3899

mperklin opened this issue Mar 14, 2019 · 3 comments · Fixed by #3903

Comments

@mperklin
Copy link

mperklin commented Mar 14, 2019

Summary of Bug

When the user uses the gaiacli config node command to set the node value, the new value is written successfully to the ~/.gaiacli/config/config.toml file, however a new line is created with characters from the previously-set node value.
In short, using the gaiacli config node <newvalue> command will break your config.toml file.

This seems to only occur when the new node value has 2-or-more fewer characters than the old/original node value.

Steps to Reproduce

  1. Install cosmos-sdk and ensure gaiacli is working as expected
  2. Set an initial node value that is somewhat long by issuing the command: gaiacli config node my_local_host:26657. Note that this new value is 19 characters long.
  3. Confirm the value exists in the config.toml file by issuing the command: cat ~/.gaiacli/config/config.toml. You should see the following output in your terminal:
node = "my_local_host:26657"
  1. Set a new node value that is shorter than the value you set in step 2 by issuing the command: gaiacli config node localhost:26657. Note that this new value is 15 characters long, 4 characters shorter than the value in step test in tests/tendermint/main.go fails #2 above
  2. Confirm the value written to the config.toml file by issuing the command: cat ~/.gaiacli/config/config.toml. You should see the following output in your terminal:
node = "localhost:26657"
57"

Note that three characters (57") are now present on the next line in the config file.
6. Attempt to perform any action with gaiacli. For example, execute the command gaiacli status
7. Observe the following error message:

ERROR: While parsing config: (3, 1): unexpected token

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@okwme
Copy link
Contributor

okwme commented Mar 14, 2019

just ran into this too

@mperklin
Copy link
Author

mperklin commented Mar 14, 2019

Upon further playing, I now believe the value is blindly overwritten by the gaiad config node command.

If the value is the same length or greater, the overwrite works as expected.
However, if the value is shorter in length, the \n character from the new value overwrites the old value, leaving the remaining characters from the old value present in the file.

In my example above with a 19-char value overwritten by a 15-char value, 4 characters remain.
However the first character is overwritten by the new value's \n, leaving three characters visible "on the next line"

@alexanderbez
Copy link
Contributor

Wow great catch guys! We should fix this asap -- doesn't look terribly difficult.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants