zkapp-cli
zkapp-cli copied to clipboard
Handle cases where `config.json` is either empty or malformed.
Description
Given the case where a user deletes their config.json
, the command zk config
will not work. If we create an empty config.json
, the CLI will still give errors that don't indicate how to move forward.
For cases where config.json
is empty, we can fill in the scaffolded values being:
{
"version": 1,
"networks": {}
}
For cases where the json input is malformed, we can give a different error message which gives some hints on what is going wrong.
@MartinMinkov Reviewing issues with Yoni. I recall this was surfaced during a code review. But we haven't encountered this in the real world ever have we? If so, would consider closing this. Is that ok Martin?
Yep, feel free to close :+1:
Actrually this happened to me pretty often :D I think it should be possible to delete the config to start over, and not have the CLI fail after that. I'm reopening if you don't mind, at least handling of a missing config (as opposed to: malformed config) should be very simple to implement
@mitschabaude Doing that, the dev will also create the potential for conflicts within their keys
directory. While I'd be okay supporting the ability to delete the config file to start afresh, I don't think we should officially support that in that I don't think it's worth it or wise for us to attempt to delete keys to clean up any that existed from a previous config or to even handle scenarios when they exist and a dev attempts to add a deploy alias with the same-as-a-preexisting name. IOW, we can partially support what you're suggesting, but shouldn't attempt to do so officially or fully imo.