foreman_ansible icon indicating copy to clipboard operation
foreman_ansible copied to clipboard

Fixes #37417 - OverriddenAnsibleVariablePresenter GraphQL scheme incorrect for hidden_value and override

Open Thorben-D opened this issue 9 months ago • 5 comments

In the model AnsibleVariable, there is hidden_value, which returns "*****" and there is hidden_value**?**, which returns a boolean. For GraphQL, the method name must be the same as the value entered in the gql-query. By delegating hidden_value**?**, the original author effectively named the gql-field "hidden_value?", which is not allowed and was therefore not working. The same applies to override.

This is fixed by wrapping the value of hidden_value**?** in a new method hidden_value in the presenter.

Required by #717

Thorben-D avatar May 08 '24 12:05 Thorben-D

@stejskalleos can you please review this?

sbernhard avatar Jul 31 '24 14:07 sbernhard

I'm unclear on what exactly isn't working and what we're trying to fix with these changes. Additionally, I'm not sure where the new methods are being used.

nofaralfasi avatar Aug 18 '24 13:08 nofaralfasi

In the AnsibleVariable model, hidden_value returns a series of asterisks, while hidden_value? returns a boolean. The author's intention was to delegate hidden_value?, but this led to an illegal field name "hidden_value?" in the GraphQL query. Similarly, override? faced the same issue. This has been rectified by wrapping hidden_value? in a new method named hidden_value within the presenter.

Thorben-D avatar Aug 28 '24 08:08 Thorben-D

In the AnsibleVariable model, hidden_value returns a series of asterisks, while hidden_value? returns a boolean. The author's intention was to delegate hidden_value?, but this led to an illegal field name "hidden_value?" in the GraphQL query. Similarly, override? faced the same issue. This has been rectified by wrapping hidden_value? in a new method named hidden_value within the presenter.

The override and hidden_value fields are defined in the AnsibleVariable type, while the OverridenAnsibleVariablePresenter acts as a bridge between the raw Ansible variable data and the GraphQL API, ensuring that values are properly resolved and presented to the client. However, in the current version of the hostVariableOverrides query, neither override nor hidden_value are included. The exclusion of override seems intentional due to its straightforward nature, but the hidden_value field could be incorporated into the query with the correct logic.

nofaralfasi avatar Aug 28 '24 10:08 nofaralfasi

You're right, right now neither hidden_value nor override is queried. This PR is a prerequisite to #717, which needs the hidden_value field via the gql-query. I should have linked those bi-directionally...

Thorben-D avatar Aug 28 '24 11:08 Thorben-D