purpleidea / mgmt

Next generation distributed, event-driven, parallel config management!
https://purpleidea.com/tags/mgmtconfig/
GNU General Public License v3.0
3.65k stars 314 forks source link

Usability bug: Add accurate error message for mcl scripts #537

Closed dbakong closed 5 years ago

dbakong commented 5 years ago

Versions:

Description:

The error message when running an mcl script with a non-existent field needs to be fixed.

mcl file:

$noop = false
exec "exec1" {
    cmd => "pwd",
    shell => "/bin/bash",
    Meta:autoedge => true,
    group => "group1",
    gid => 110,
}

user "user1" {
    state => "exists",
    Meta:autoedge => true,
    group => "group1",
}

user "user2" {
    state => "exists",
    group => "group2",
    Meta:autoedge => true,
}

group "group1" {
    state => "exists",
    gid => 110,
    Meta:autoedge => true,
}

group "group2" {
    state => "exists",
    gid => 111,
    Meta:autoedge => true,
}

log of failed run:

2019-09-07 22:13:46.852235 I | cli: lang: lexing/parsing...
2019-09-07 22:13:46.872282 I | cli: lang: init...
2019-09-07 22:13:46.872368 I | cli: lang: interpolating...
2019-09-07 22:13:46.872489 I | cli: lang: building scope...
2019-09-07 22:13:46.872911 I | cli: lang: running type unification...
2019-09-07 22:13:46.873209 I | run: error: cli parse error: could not unify types: could not determine type for `gid` field of `exec`
purpleidea commented 5 years ago

I actually already patched this in a feature branch. Coming to git master shortly. Thanks!

purpleidea commented 5 years ago

Fixed in gitmaster.