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

Approvals Api does not work with replacing rules #11

Open
chrisdurand-RL opened this issue May 12, 2022 · 7 comments
Open

Approvals Api does not work with replacing rules #11

chrisdurand-RL opened this issue May 12, 2022 · 7 comments
Labels

Comments

@chrisdurand-RL
Copy link

When doing a rule replacement, the semantic patch expects the field variationId to be present. However, the internal model for Rule has a property variation. These are incompatible and the service throws an error.

import launchdarkly_api
from launchdarkly_api.api import  approvals_api

configuration = launchdarkly_api.Configuration()
configuration.api_key["ApiKey"] = API_KEY
api_client = launchdarkly_api.ApiClient(configuration)
approvals_client = approvals_api.ApprovalsApi(api_client)

rules = [
    Rule(
        clauses=[
            Clause(attribute="service", negate=False, op="in", values=['fake-service']),
        ],
        variation=0,
        track_events=False,
    )
]

approval_request = CreateFlagConfigApprovalRequestRequest(
    comment="comment",
    description="description",
    instructions=Instructions([
        Instruction(
            kind="replaceRules",
            rules=rules
        ),
    ]),
    notify_member_ids=['my_id_number']
)

approvals_client.post_approval_request('project', 'TEST_FLAG', 'test', approval_request)
{"code":"invalid_request","message":"rule index 0: instruction variationId or rolloutWeights must be specified"}

As you can see from the model for Rule, the attribute is called variation, not variationId.
I can try to use a raw dictionary that conforms to the semantic patch pattern, but then I get a different error:

configuration = launchdarkly_api.Configuration()
configuration.api_key["ApiKey"] = API_KEY
api_client = launchdarkly_api.ApiClient(configuration)
approvals_client = approvals_api.ApprovalsApi(api_client)

rules = [
    Rule(
        clauses=[
            Clause(attribute="service", negate=False, op="in", values=['fake-service']),
        ],
        variation=0,
        track_events=False,
    )
]

approval_request = CreateFlagConfigApprovalRequestRequest(
    comment="comment",
    description="description",
    instructions=Instructions([
        Instruction(
            kind="replaceRules",
            rules=[
                {
                    "variationId": 1,
                    "clauses":  [
                        {
                            "attribute": "service",
                            "op": "in",
                            "negate": False,
                            "values": ["fake-service"]
                        }
                    ],
                }
            ]
        ),
    ]),
    notify_member_ids=['my-member-id']
)

approvals_client.post_approval_request('project', 'TEST_FLAG', 'test', approval_request)
AttributeError: 'dict' object has no attribute '_composed_schemas'
@carmenquan
Copy link

Thanks again @chrisdurand-RL - I'm following up with my team and will get back to you with a timeline for a fix.

@carmenquan carmenquan added the bug label May 12, 2022
@tonyurso-RL
Copy link

Hi there,

Any update here? Our launch is currently blocked on this issue. Who can we reach out to can an update?

@carmenquan
Copy link

Hi @tonyurso-RL, we are actively investigating the issues and working towards a new release with all the identified fixes. I'll update when we have a clear timeline to provide.

@tonyurso-RL
Copy link

tonyurso-RL commented May 13, 2022 via email

@carmenquan
Copy link

Hi @tonyurso-RL,

The correct way to populate instructions for this request is using the raw dictionary, not using the model for Rule directly. However, the error you are seeing when you do that is related to the open-source openapi generator that we rely on to generate our client library, and we're currently investigating. Unfortunately I don't have a workaround other than making a request without our client library to unblock yourself, but we are actively working to get a new release out.

@chrisdurand-RL
Copy link
Author

Hello, do you have any updates for this bug?

@Selina-LD
Copy link

Selina-LD commented May 17, 2022

Hey Chris, just sent you an email with an update.

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

No branches or pull requests

4 participants