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

config corruption #274

Open
mixmix opened this issue Oct 31, 2024 · 1 comment
Open

config corruption #274

mixmix opened this issue Oct 31, 2024 · 1 comment
Assignees

Comments

@mixmix
Copy link
Contributor

mixmix commented Oct 31, 2024

We've see several instances of config corruption

It should not be possible, and if it happens (user or other program mutated config), then we should get more info.

To consider:

  • atomic read/ write (lockfile?)
  • write-lock in CLI code
  • validation of input to config.set
    • is it an object?
    • does it have required fields?
      • JSON schema
@mixmix
Copy link
Contributor Author

mixmix commented Dec 2, 2024

Tasks

  • 1.write isValidConfig function

    • use JSON Schema + AJV
      • it's good learning
      • JSON Schema can be used in other languages
      • check it outputs detailed errors (e.g. "missing .accounts")
    • MUST have required fields, subfields
    • SHOULD allow for additional fields (if users wanna put junk in there)
    • write tests
      isValidConfig(goodConfig)
      // => true
      isValidConfig.errors = []
      
      isValidConfig(badConfig)
      // => false
      isValidConfig.errors = [
        "config.selectedAccount must be a string",  // examples, hopefully AJV has clear output
        "config.accounts missing"
      ]
  • 2. add isValidConfig check to config.set

    • should throw error if someone tries to set a bad config
    • should NOT write
    • write tests
  • 3. research how / where to guard config.get

    • we want to guard against ingesting bad config into Entropy
    • we need to be able to read "old" config that might not be "right" but should be once we migrate
    • should each migration have a schema associated with it
    • Produce a new issue describing what you find, then a proposed solution
  • 4. review the code base

    • look for places config is used, whether there are other places we want isValidConfig

@frankiebee frankiebee removed this from the Function Completeness milestone Dec 2, 2024
@mixmix mixmix added this to the Function Completeness milestone Dec 4, 2024
@mixmix mixmix self-assigned this Dec 5, 2024
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

No branches or pull requests

2 participants