-
Problem report
-
Resolution: Cannot Reproduce
-
Blocker
-
None
-
4.2.7
I have a master item that gets item data like this (HTTP agent):
{"strings":["AutoFullBackup-20190912_160006","AutoFullBackup-20190913_160125","AutoFullBackup-20190914_160232","AutoFullBackup-20190915_160343","AutoFullBackup-20190916_160453","AutoFullBackup-20190917_160606","AutoFullBackup-20190918_160716","AutoFullBackup-20190919_160835","AutoFullBackup-20190920_161000","AutoFullBackup-20190921_161111","AutoFullBackup-20190922_161219","AutoFullBackup-20190924_140600","AutoFullBackup-20190925_140714","AutoFullBackup-20190926_140825","AutoFullBackup-20190927_140940","AutoFullBackup-20190928_141050","AutoFullBackup-20190929_141200","AutoFullBackup-20190930_141312","AutoFullBackup-20191001_141426","AutoFullBackup-20191002_141541","AutoFullBackup-20191003_141651"]}
Then I have 2 dependent items which turn to unsupported with an error:
- Item: Number of backups
Preprocessing: JSONPath: $.strings.length()
Error:Preprocessing failed for: {"strings":["AutoFullBackup-20190912_160006","AutoFullBackup-20190913_160125","AutoFullBackup-201... 1. Failed: cannot extract value from json by path "$.strings.length()": object not found starting with json path: "length()"
- Item: Last backup
Preprocessing: JSONPath: $.strings[-1]
Error:Preprocessing failed for: {"strings":["AutoFullBackup-20190912_160006","AutoFullBackup-20190913_160125","AutoFullBackup-201... 1. Failed: cannot extract value from json by path "$.strings[-1]": unsupported character in json path starting with: "[-1]"{color}
However, when I copy-paste the data from the master item into the Preprocessing test dialog of the web UI.. I do get the expected results:
For Item 1 I get "21" as test result
and for item 2 I get "AutoFullBackup-20191003_141651" as test result
Steps to reproduce:
- Create master item, and feed it with this JSON string (I get this data using a HTTP agent, but I assume a trapper would suffice):
{"strings":["AutoFullBackup-20190912_160006","AutoFullBackup-20190913_160125","AutoFullBackup-20190914_160232","AutoFullBackup-20190915_160343","AutoFullBackup-20190916_160453","AutoFullBackup-20190917_160606","AutoFullBackup-20190918_160716","AutoFullBackup-20190919_160835","AutoFullBackup-20190920_161000","AutoFullBackup-20190921_161111","AutoFullBackup-20190922_161219","AutoFullBackup-20190924_140600","AutoFullBackup-20190925_140714","AutoFullBackup-20190926_140825","AutoFullBackup-20190927_140940","AutoFullBackup-20190928_141050","AutoFullBackup-20190929_141200","AutoFullBackup-20190930_141312","AutoFullBackup-20191001_141426","AutoFullBackup-20191002_141541","AutoFullBackup-20191003_141651"]}
- Create dependent item:
- Name: Database auto-backup: number of available backups
- Type: Dependent item
- Master Item: (key of master item)
- Type of information: Numeric (unsigned)
- Preprocessing:
- JSONpath: $.strings.length()
- Discard unchanged with heartbeat: 1h (don't know if this is relevant)
- Use the Preprocessing Test-link next to the JSONpath rule:
- Set the above JSON string as value and press test
- See that the result is 21
- Create another dependent item:
- Name: Database auto-backup: time of latest backup
- Type: Dependent item
- Master Item: (key of master item)
- Type of information: Numeric (unsigned)
- Units: unixtime
- Preprocessing: (not sure if anything after the JSONpath is relevant)
- JSONpath: $.strings[-1]
- Regular Expression: {{^AutoFullBackup-([0-9]
{4}
)([0-9]
{2})([0-9]{2})_([0-9]
{2})([0-9]{2})([0-9]
{2})$}} - \1-\2-\3 \4:\5:\6
- Javascript: return new Date(value).getTime()
- Custom multiplier: 0.001
- Discard changes with heartbeat: 1d
- Use the Preprocessing Test-link next to the JSONpath rule:
- Set the above JSON string as value and press test
- See that the result equals AutoFullBackup-20191003_141651
- You can try the "Test all steps"-link. This should result in a valid unixtime.
Result:
For item 1: Turns unsupported with error:
Preprocessing failed for: {"strings":["AutoFullBackup-20190912_160006","AutoFullBackup-20190913_160125","AutoFullBackup-201...
1. Failed: cannot extract value from json by path "$.strings.length()": object not found starting with json path: "length()"
For item 2: Turns unsupported with error:
Preprocessing failed for: {"strings":["AutoFullBackup-20190912_160006","AutoFullBackup-20190913_160125","AutoFullBackup-201...
1. Failed: cannot extract value from json by path "$.strings[-1]": unsupported character in json path starting with: "[-1]"
Expected:
Item 1 value: 21
Item 2 value: 1570112211