Skip to content
Snippets Groups Projects
Commit c9b8c5da authored by STEVAN Antoine's avatar STEVAN Antoine :crab:
Browse files

add runtime checks for `--fec-params` in `komodo prove` (dragoon/komodo!49)

@n.dissoubray found a bug when not passing `--fec-params` to `komodo prove` where
- `null` cannot be accessed
- invalid keys in `$fec_params` might be accessed and crash the command

this MR adds runtime checks for the type of `--fec-params`, to make sure it's
- non `null`
- has a valid shape
parent 770ce024
No related branches found
No related tags found
No related merge requests found
......@@ -141,6 +141,26 @@ export def "komodo prove" [
--encoding-method: string@"nu-complete encoding-methods" = "random", # the encoding method, e.g. _random_ or _vandermonde_
--log-level: string@"nu-complete log-levels" = $DEFAULT_LOG_LEVEL # change the log level
]: nothing -> list<string> {
# NOTE: the next two runtime checks on the type of `--fec-params` might be
# a bug on the Nushell side
if $fec_params == null {
error make --unspanned {
msg: "`komodo prove` requires `--fec-params` to be given"
}
}
let type = $fec_params | describe --detailed | update columns { sort }
let expected = { type: record, lazy: false, columns: { k: int, n: int } }
if $type != $expected {
error make {
msg: $"(ansi red_bold)invalid `--fec-params`(ansi reset)",
label: {
text: $"expected ($expected) got ($type)",
span: (metadata $fec_params).span,
}
}
}
(
run-komodo
--log-level $log_level
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment