Skip to content

Improve handling ALL_PROPOSALS_PARAMETERS_JSON #3273

@mnaamani

Description

@mnaamani

There a few issues with how invalid ALL_PROPOSALS_PARAMETERS_JSON affects behavior

1 - invalid JSON is not caught at build time or when running tests
2 - comments describe behavior such that improper json will cause a fallback to defaults. This is not the case, the runtime panics instead. Which behavior do we want?
3 - Its not clear how negative numbers (valid json number) in the JSON processed.
4 - option_env!("ALL_PROPOSALS_PARAMETERS_JSON") handles empty string and null differently on Linux vs Mac this has resulted in compiling a runtime where an empty string was set for the variable, which caused the runtime to panic with ""Invalid JSON with proposals parameters provided." since an empty string returned an error by lite_json::parse_json()

Proposal
1 - try to catch invalid json during build if possible, or at minimum in unit tests
2 - I think fallback is better than panic!
3 - Will test
4 - Add explicit handling of empty string or variable not set to both result in "default" values being used.

┆Issue is synchronized with this Asana task by Unito

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingruntime

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions