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

[AppConfig] Missing quotes for "If-Match" etag header #13276

Closed
avanigupta opened this issue Aug 23, 2020 · 1 comment
Closed

[AppConfig] Missing quotes for "If-Match" etag header #13276

avanigupta opened this issue Aug 23, 2020 · 1 comment
Assignees
Labels
App Configuration Azure.ApplicationModel.Configuration Client This issue points to a problem in the data-plane of the library.

Comments

@avanigupta
Copy link
Member

avanigupta commented Aug 23, 2020

def set_read_only(
self, configuration_setting, read_only=True, **kwargs
): # type: (ConfigurationSetting, Optional[bool], dict) -> ConfigurationSetting
"""Set a configuration setting read only
:param configuration_setting: the ConfigurationSetting to be set read only
:type configuration_setting: :class:`ConfigurationSetting`
:param read_only: set the read only setting if true, else clear the read only setting
:type read_only: bool
:keyword dict headers: if "headers" exists, its value (a dict) will be added to the http request header
:return: The ConfigurationSetting returned from the service
:rtype: :class:`ConfigurationSetting`
:raises: :class:`HttpResponseError`, :class:`ClientAuthenticationError`, :class:`ResourceNotFoundError`
Example
.. code-block:: python
config_setting = client.get_configuration_setting(
key="MyKey", label="MyLabel"
)
read_only_config_setting = client.set_read_only(config_setting)
read_only_config_setting = client.set_read_only(config_setting, read_only=False)
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError
}
try:
if read_only:
key_value = self._impl.put_lock(
key=configuration_setting.key,
label=configuration_setting.label,
error_map=error_map,
**kwargs
)
else:
key_value = self._impl.delete_lock(
key=configuration_setting.key,
label=configuration_setting.label,
error_map=error_map,
**kwargs
)
return ConfigurationSetting._from_key_value(key_value)
except ErrorException as error:
raise HttpResponseError(message=error.message, response=error.response)

While trying to use the lock/unlock API like this:
kv = azconfig_client.set_read_only(configurationSetting, if_match=configurationSetting.etag)

I noticed that the If-Match etag request header is not properly quoted while constructing the request here.

Instead of passing if_match argument with set_read_only, it would be better if we could just pass the match_condition argument like in all other methods in this module (for example: here, quotations are handled properly).

@ghost ghost added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Aug 23, 2020
@kaerm kaerm added App Configuration Azure.ApplicationModel.Configuration Client This issue points to a problem in the data-plane of the library. labels Aug 24, 2020
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Aug 24, 2020
@xiangyan99
Copy link
Member

Fixed.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
App Configuration Azure.ApplicationModel.Configuration Client This issue points to a problem in the data-plane of the library.
Projects
None yet
Development

No branches or pull requests

3 participants