[suggestion] Enhance configuration parsing with precise field locations #3470
Labels
config-changes
Changes in configuration and start up of the Iroha
Enhancement
New feature or request
iroha2-dev
The re-implementation of a BFT hyperledger in RUST
Feature request
I would like to get meaningful errors when I pass configuration (via JSON, ENV vars or both) to Iroha 2.
Consider the following cases that currently occur:
I have passed
PUBLIC_KEY
andPRIVATE_KEY
env vars, and I get an error:It turned out that yes, in JSON configuration I could provide them as top-level fields with these names, but when it comes to ENV, I should specify them as
IROHA_PUBLIC_KEY
andIROHA_PRIVATE_KEY
.By the way: yes, it prints exactly "
PUBLIC_KEY AND PRIVATE_KEY
", not "PUBLIC_KEY
andPRIVATE_KEY
".The descriptive error would be:
I forgot to specify the P2P addr:
The descriptive error would be:
Thoughts on implementation
Introduce a data structure for configuration parameter location:
Then refactor the configuration proc macros so they can generate all of the locations in order to use them statically.
Sample macro usage:
Generated modules
Then, this code could be used in other parts to throw descriptive errors, like that:
Motivation
Iroha will be even more useful if it throws descriptive and helpful errors when misconfiguration happens.
Also, it will be useful for #2373 - the tool will be able to define ENV variables in a docker-compose configuration with static check.
Who can help?
No response
The text was updated successfully, but these errors were encountered: