# Warning at Service - "leading/trailing whitespace"

**URL:** <https://community.icinga.com/t/warning-at-service-leading-trailing-whitespace/15600>\
**Category:** Icinga 2\
**Created:** [October 1, 2026, 6:52pm UTC](https://community.icinga.com/t/warning-at-service-leading-trailing-whitespace/15600 "2026-10-01T18:52:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![KlStz](https://community.icinga.com/letter_avatar_proxy/v4/letter/k/7c8e57/32.png) [@KlStz](https://community.icinga.com/u/KlStz)\
**Post date:** [October 1, 2026, 6:52pm UTC](https://community.icinga.com/t/warning-at-service-leading-trailing-whitespace/15600/1 "2026-10-01T18:52:38Z")

</div>

Sometimes it happens, that user create dictionaries which ared use to create services, which contains leading or trailing white(spaces).

Unfortunately I overlook such warnings (sometimes)

`apply Service "servicename-" for ( desc => config in host.vars.servicedict ) {`  
`....`  
` display_name = "servicename: " + desc.trim()`  
`}`  
I can trim() display\_name and notes but not the service

The applied services are running perfect.

Has someone a idea, whether it’s possible to prevent such a warning.

---

<div class="post-metadata">

**Author:** ![KlStz](https://community.icinga.com/letter_avatar_proxy/v4/letter/k/7c8e57/32.png) [@KlStz](https://community.icinga.com/u/KlStz)\
**Post date:** [October 2, 2026, 8:15am UTC](https://community.icinga.com/t/warning-at-service-leading-trailing-whitespace/15600/2 "2026-10-02T08:15:03Z")

</div>

Hi everyone

this is my actual solution:  
I must use a helper function, wich use trim() to clean the dictionary keys and returns a rebuilded perfect dictionary to to apply …

```auto
globals.trimDictionaryKeys = function(dict) {
var result = {}

for (key => value in dict) {
    result[key.trim()] = value
}

return result

}

```

`apply Service "servicename-" for ( desc => config in trimDictionaryKeys(host.vars.servicedict) ) {`  
`....`  
` display_name = "servicename: " + desc.trim()`  
`}`

If somebody have a better solution please answer
