Open GeosMeos opened 5 months ago
Hi @GeosMeos thanks for creating an issue. I've identified a bug related to what you've posted here, and created a ticket to resolve it. The API should have thrown an error based on your provided path
.
In case you weren't already aware, the correct path in your snippet should be /environments/test/offVariation
- we camel-case fields in our JSON representations.
@tvarney13 i've assumed so as the API is pointing to offVariation but when I try to update it, an error is returned:
HTTP response body: {"code":"not_found","message":"Invalid resource identifier"}
here's the snippet:
patch_off_variation = PatchWithComment(
patch=JSONPatch(
[
PatchOperation(
op="replace",
path="/environments/test/offVariation",
value=prod_config["offVariation"],
),
]
),
comment=f"{project_key}-patch-off_variation",
)
api_response = api_instance.patch_feature_flag(
project_key, feature_flag_key, patch_off_variation
)
@GeosMeos So in this case I was actually wrong about the path, you were right before. Sorry about that, I usually support the APIs themselves not these client libraries.
I attempted a similar request on a test flag in Postman and it worked, so just to verify - you're seeing that the value for the offVariation
in the test
environment remains 0
after the patch?
Here's my test request (the offVariation was set to 1
beforehand):
Hmmm, I was successfully able to update the off variation with the following:
with launchdarkly_api.ApiClient(configuration) as api_client:
api_instance = feature_flags_api.FeatureFlagsApi(api_client)
project_key = "my-project"
feature_flag_key = "new-flag"
patch_off_variation = feature_flags_api.PatchWithComment(
patch = JSONPatch([
PatchOperation(
op="replace",
path="/environments/test/offVariation",
value=1,
),
]),
comment="patch-off_variation",
)
try:
# Update feature flag
api_response = api_instance.patch_feature_flag(project_key, feature_flag_key, patch_off_variation)
pprint(api_response)
except launchdarkly_api.ApiException as e:
print("Exception when calling FeatureFlagsApi->patch_feature_flag: %s\n" % e)
Just to clarify, what you want to do is update the value of the flag when the flag is off? Printing the API response, this should be the value that you see updated:
{'environments':{
...
'test': {'archived': False,
...
'off_variation': 1,
I'm trying to patch off_variation in a specific environment(test in this case)
The following doesn't work(Note that i've taken this example from auto generated examples:
This however works with other fields such as
on
orfallthrough.variation
I've tried int and str, expected an error but operation returns 200.
Version(from pip freeze) launchdarkly-api @ git+https://github.com/launchdarkly/api-client-python.git@9bdc16d79381a1f03c8a51dd69323c80a13a286d