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

fnJq regression #113

Closed
hmarko opened this issue Nov 19, 2023 · 7 comments
Closed

fnJq regression #113

hmarko opened this issue Nov 19, 2023 · 7 comments

Comments

@hmarko
Copy link

hmarko commented Nov 19, 2023

Hi there Mr Guy!

I think something changed from previous versions.

This used to work:

  • type: expression
    name: flat_service_info
    expression: "fn.fnJq($(settings),'.|[leaf_paths as $path|{key: $path|join("^"), value: getpath($path)}]')"
    hide: true
    noOutput: true

It’s working using jq CLI :

[root@centos1 forms]# cat /tmp/a.json | jq '.| [leaf_paths as $path | {"key": $path | join("^"), "value": getpath($path)}]'
[
{
"key": "Home Dir^koko^yoyo^jojo^prod^cifsaccess^ntfs_acls^acls^0^access",
"value": "modify"
},

AF log entry returns this:

2023-11-19 10:09:42:942 error: Error in fnJq : jq: error: leaf_paths/0 is not defined at , line 1:
def fn2KB: ./1024;def fn2MB: ./1024/1024;def fn2GB: ./1024/1024/1024;def fnRound0: .*1.0 + 0.5|floor/1.0;def fnRound1: .*10.0 + 0.5|floor/10.0;def fnRound2: .*100.0 + 0.5|floor/100.0;def fnRound: .*100.0 + 0.5|floor/100.0;.services|[leaf_paths as $path|{key: $path|join("^"), value: getpath($path)}]

for testing purposes, it should work on any JSON input

@ansibleguy76
Copy link
Owner

ansibleguy76 commented Nov 19, 2023 via email

@hmarko
Copy link
Author

hmarko commented Nov 19, 2023

Hi.

Found the issue, not related to AF.

This stopped working also between jq 1.6 to jq 1.7 in the CLI

[root@centos1 forms]# jq --version
jq-1.6
[root@centos1 forms]# /tmp/jq-linux-amd64 --version
jq-1.7

/tmp/jq-linux-amd64 '. | [leaf_paths as $path | {"key": $path | join("^"), "value": getpath($path)}]' /tmp/a.json
jq: error: leaf_paths/0 is not defined at , line 1:
. | [leaf_paths as $path | {"key": $path | join("^"), "value": getpath($path)}]

IS there any chance to downgrade your node-js package ?

@ansibleguy76
Copy link
Owner

ansibleguy76 commented Nov 19, 2023 via email

@hmarko
Copy link
Author

hmarko commented Nov 19, 2023

looks like a new bug

@hmarko
Copy link
Author

hmarko commented Nov 19, 2023

jqlang/jq#2666

@ansibleguy76
Copy link
Owner

      `leaf_paths` is an alias of `paths(scalars)`; `leaf_paths` is
      `leaf_paths` is an alias of `paths(isscalar)`; `leaf_paths` is
      *deprecated* and will be removed in the next major release.

This is in version 1.6.2. leaf_paths is an alias and will be deprecated.

Now, how unfortunate this is for you, I can't just stay on older version because of deprecated code.

@ansibleguy76
Copy link
Owner

This is closed... it's a deprecated jq issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants