Skip to content

setting config options from cli may break config #740

Closed

Description

@jbenet

setting the repo's Log.MaxSizeMB from the cli breaks the config:

> ipfs config Log.MaxSizeMB
0
> ipfs config Log.MaxSizeMB 100
Error: Failed to set config value: Failure to decode config: json: cannot unmarshal string into Go value of type uint64
> ipfs config Log.MaxSizeMB
Error: Failure to decode config: json: cannot unmarshal string into Go value of type uint64
> ipfs config edit
Error: Failure to decode config: json: cannot unmarshal string into Go value of type uint64

the config got a string:

  "Log": {
    "MaxAgeDays": 0,
    "MaxBackups": 0,
    "MaxSizeMB": "100"
  },

changing it to an int fixes it. BUT:

  • this shouldnt break, and
  • this should be recoverable from the cli.
    objects retrieving values from the config should try to parse them from the string.

Activity

  1. btc commented on Feb 4, 2015

    @btc
    Contributor

    One part of this problem is that the config is written to disk before it is validated against the Config struct. (Recall: users are allowed to set keys that don't exist on the struct) This is fixed in #742.

  2. changed the title [-]setting config options from cli make break config[/-] [+]setting config options from cli may break config[/+] on Mar 28, 2015
  3. jbenet commented on May 19, 2015

    @jbenet
    MemberAuthor

    @rht thanks for picking this up.

    I've since implemented the --json option, so maybe we could ask users to use --json. Check it out at:
    https://github.com/ipfs/go-ipfs/blob/master/core/commands/config.go#L79-L87

    not sure, what do you think is most intuitive?

  4. rht commented on May 19, 2015

    @rht
    Contributor

    Depends on how the config is used. I will check how postfix, vault, etc nail this, and why.

  5. rht commented on May 19, 2015

    @rht
    Contributor
    • current state
      Since '--json' supersedes '--bool', should we get rid of the latter?
      Otherwise if '--bool' is kept then '--integer' (this issue) and '--number' (float type) need to exist, for consistency.
      The bug (for integer case) itself has been fixed by when setting config keys, validate against struct before writing to disk #742
    • what other tools use
    • tests
      • integer
        ipfs config atoms/mol 11666 -> "atoms/mol": 11666
      • number
        • ipfs config atoms/mol 11666.66 -> "atoms/mol": "11666.66"
        • ipfs config --json atoms/mol 11666.66 -> "atoms/mol": 11666.66
        • ipfs config --json atoms/mol "11666.66" -> "atoms/mol": 11666.66
        • ipfs config --json atoms/mol "\"11666.66\"" -> "atoms/mol": "11666.66"

    From the test result, for intuitiveness sake I'd say why not assume the value is json by default and then put escaped quote around numbers when you need them to be string (e.g. the value of Version.CheckPeriod? Why this is string I have no idea).

  6. rht commented on Jul 14, 2015

    @rht
    Contributor

    @jbenet This is fixed.

  7. jbenet commented on Jul 14, 2015

    @jbenet
    MemberAuthor

    @rht, that's right, thanks!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions