Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dev.icinga.com #8002] typeof() seems to return null for arrays and dictionaries #2380

Closed
icinga-migration opened this issue Dec 5, 2014 · 10 comments
Labels
area/configuration DSL, parser, compiler, error handling bug Something isn't working
Milestone

Comments

@icinga-migration
Copy link

This issue has been migrated from Redmine: https://dev.icinga.com/issues/8002

Created by tobiasvdk on 2014-12-05 07:05:29 00:00

Assignee: gbeutner
Status: Resolved (closed on 2014-12-08 07:37:04 00:00)
Target Version: 2.2.2
Last Update: 2014-12-10 09:19:07 00:00 (in Redmine)

Icinga Version: 2.2.1

The assign conditions are not checked successively, e.g. if you have object vars which can be an array or a dictionary.

Simple Host config:

object Host "my-host" {
  import "generic-host"

  address = "127.0.0.1"

  vars.disks["disk"] = {
    /* No parameters. */
  }
  vars.disks["disk /"] = {
    disk_partitions = "/"
  }
}

Simple Service config:

apply Service for (disk in host.vars.disks) {
  import "generic-service"

  check_command = "disk"

  assign where typeof(host.vars.disks) == typeof([]) && "/" in host.vars.disks
}

The error:

/etc/icinga2/conf.d/services.conf(84):   assign where typeof(host.vars.disks) == typeof([]) && "/" in host.vars.disks
                                                                                                                                                                       ^^^^^^^^^^^^^^^^
/etc/icinga2/conf.d/services.conf(85): }
/etc/icinga2/conf.d/services.conf(86): 

Config error: Error while evaluating expression: Invalid right side argument for 'in' operator: {"disk":{},"disk /":{"disk_partitions":"/"}}

Using icinga 2.2.1 from debian unstable on debian wheezy.

Changesets

2014-12-08 07:36:03 00:00 by gbeutner 04ca634

Fix typeof incorrectly returning null for arrays and dictionaries

fixes #8002

2014-12-08 07:36:47 00:00 by gbeutner e3673bf

Fix typeof incorrectly returning null for arrays and dictionaries

fixes #8002

2014-12-08 10:03:50 00:00 by gbeutner 37ffda1

Add unit tests for the typeof() operator

refs #8002
@icinga-migration
Copy link
Author

Updated by tobiasvdk on 2014-12-05 08:11:29 00:00

Also happens with git commit 795b5b8

@icinga-migration
Copy link
Author

Updated by gbeutner on 2014-12-05 09:15:19 00:00

  • Target Version set to 2.2.2

Probably a problem with operator precedence (in vs. &&).

@icinga-migration
Copy link
Author

Updated by gbeutner on 2014-12-05 14:02:30 00:00

 ^ host = { vars = { disks = {} } }
 ( host = { vars = { disks = {} } } ) = {"vars":{"disks":{}}}
 ^ typeof(host.vars.disks) == typeof([]) && "/" in host.vars.disks
 ( typeof(host.vars.disks) == typeof([]) && "/" in host.vars.disks ) = Error while evaluating expression: Invalid right side argument for 'in' operator: {}

@icinga-migration
Copy link
Author

Updated by gbeutner on 2014-12-05 14:04:10 00:00

typeof() seems to return null for arrays and dictionaries:

 ^ typeof({})
 ( typeof({}) ) = null
 ^ typeof([])
 ( typeof([]) ) = null

@icinga-migration
Copy link
Author

Updated by tobiasvdk on 2014-12-05 14:46:22 00:00

gunnarbeutner wrote:

typeof() seems to return null for arrays and dictionaries:
This is a boost "problem", isn't it?

@icinga-migration
Copy link
Author

Updated by gbeutner on 2014-12-05 15:01:29 00:00

  • Subject changed from assign conditions are not checked successively to typeof() seems to return null for arrays and dictionaries

@icinga-migration
Copy link
Author

Updated by gbeutner on 2014-12-05 15:02:02 00:00

Nope, this has nothing to do with Boost. The problem is that GetReflectionType() returns NULL for certain built-in Icinga types.

@icinga-migration
Copy link
Author

Updated by gbeutner on 2014-12-05 15:06:29 00:00

This is fixed in the validator branch.

@icinga-migration
Copy link
Author

Updated by gbeutner on 2014-12-08 07:37:04 00:00

  • Status changed from New to Resolved
  • Done % changed from 0 to 100

Applied in changeset 04ca634.

@icinga-migration
Copy link
Author

Updated by gbeutner on 2014-12-10 09:19:07 00:00

  • Assigned to set to gbeutner

@icinga-migration icinga-migration added bug Something isn't working area/configuration DSL, parser, compiler, error handling labels Jan 17, 2017
@icinga-migration icinga-migration added this to the 2.2.2 milestone Jan 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/configuration DSL, parser, compiler, error handling bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant