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

set_fact - Missing property "key_value" #261

Open
lsabalo opened this issue Mar 6, 2020 · 15 comments
Open

set_fact - Missing property "key_value" #261

lsabalo opened this issue Mar 6, 2020 · 15 comments

Comments

@lsabalo
Copy link

lsabalo commented Mar 6, 2020

Environment

  • Extension version: 0.5.2
  • OS Type: MacOS

Summary

VS Code wrongly shows an error where set_fact is properly formatted and it doesn't need a "key_value" property.

Reproduce steps

- name: Load configuration for DNS
  set_fact:
    dns_nameservers: "{{ var1 }}"
  when: ('mygroup' in group_names)

Expected Results

No problem reported

Actual Results

Problem: Missing property "key_value".

@jamesjrwood
Copy link

I've experienced this problem as well, seems like it would be pretty trivial to fix but it makes my playbook look like it has a lot of errors, it is distracting. Do I have something configured improperly?

@mstoetzer
Copy link

'key_value' is marked as required in the docs. Is vscode-ansible parsing the docs incorrectly?

Because adding key_value: "" removes the warning message.

@jamesjrwood
Copy link

jamesjrwood commented Apr 9, 2020

I don't think that vscode-ansible is parsing the docs incorrectly, the docs in this case are ambiguous. The docs are indicating that when you utilize set_fact you have to provide a key and a value to set for a fact, but when you set a fact the key of the fact you are setting will not necessarily be the string key_value. It would not be very useful to have every fact in your play set as key_value.

Proper use example:

- name: set a fact
  set_fact:
    foo: bar

If this case, foo is the key_value the docs are referring to.

@mstoetzer
Copy link

mstoetzer commented Apr 9, 2020

Yes, I know, just putting key_value isn't very useful.
But vscode indicates an error, that's why I was just curious:

@jamesjrwood
Copy link

jamesjrwood commented Apr 9, 2020

Yes that could be a workaround but it is messy and your playbook will end up with key_value as a fact with no value added. Personally I do not like to create variables in my playbook that are unused. In a playbook you might have many many instances of the set_fact module and it just seems silly to have to put key_value: "" in there to appease the parser.

@julian-alarcon
Copy link

So, an improvement can be make to parse the key_value requirement as the elements. Right?

@jamesjrwood
Copy link

Yes, I think so

@RylandDeGregory
Copy link

Has this been looked at? Seems like a pretty simple fix...?

@jasonfharris
Copy link

I also noticed this. A fix would be nice!

@Et0san
Copy link

Et0san commented Jun 2, 2020

I'd love to see this improvement come, too. I thought it was me doing something wrong for too long now 😁

@nifr
Copy link

nifr commented Jun 7, 2020

I don't have the ansible extension installed and I'm facing the same error message in the problem matcher throughout my playbooks.

Is it possible that this issue should be reported over at the YAML extension repository instead?
This repository seems to be abandoned (Latest commit 2201b21 on Aug 21, 2019)

Does anyone know how to trace down the origin (extension) of a problem in the problem matcher?

@karlkatzke
Copy link

The documents say "Or alternatively, accepts complex arguments using the args: statement." Which would indicate that despite "key_value" being marked as required, it's not, and this error only shows because the original developer of this module missed that hint.

Just a simple patch to remove key_value as required when there are other arg values should fix this.

@RylandDeGregory
Copy link

@yungezz @zikalino is this extension/project abandoned? Should we file a report in the YAML extension repo?

@yungezz
Copy link
Contributor

yungezz commented Jul 7, 2020

@yungezz @zikalino is this extension/project abandoned? Should we file a report in the YAML extension repo?

@mybayern1974 to help sharing next step

@pm98zz-c
Copy link

As far as I can tell this comes from redhat-developer/vscode-yaml#340 (and ultimately probably from the way Ansible describes it), not this extension.
I've not digged very far but:

  • Disabling vscode-ansible doesn't make the error disappear
  • Disabling vscode-yaml does (with vscode-ansible enabled)

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