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

Context properties are not evaluated when using /api/proxy/all #555

Closed
mikklfr opened this issue Oct 8, 2024 · 1 comment · Fixed by #558
Closed

Context properties are not evaluated when using /api/proxy/all #555

mikklfr opened this issue Oct 8, 2024 · 1 comment · Fixed by #558
Assignees
Labels
bug Something isn't working

Comments

@mikklfr
Copy link

mikklfr commented Oct 8, 2024

Describe the bug

Contextual properties should be evaluated in the same way regardless of the routing /api/proxy/all, /api/proxy or /api/frontend

Steps to reproduce the bug

  1. Create a strategy that uses context properties such as the ones defined in the test file with_custom_constraint.json

  2. Call the API using /api/proxy/all?properties[companyId]=bricks

  3. The strategy will not match the output of /api/frontend?properties[companyId]=bricks or /api/proxy?properties[companyId]=bricks

Expected behavior

Contextual properties from /api/proxy/all should be evaluated in the same way than /api/frontend and /api/proxy.
In that case the flag should be enabled when companyId=bricks

Logs, error output, etc.

No response

Screenshots

No response

Additional context

Client impact

/api/proxy/all is mandatory for Dart SDK users to be able to rely on edge to fetch unleash flags and ensure metrics propagation

How to reproduce the issue usings tests

The test can_handle_custom_context_fields in frontend_api.rs does not check the flag enabled property.
This code allows to see the difference between the different endpoints.

        let req = test::TestRequest::get()
            .uri("/api/frontend?properties[companyId]=bricks")
            .insert_header(ContentType::json())
            .insert_header(("Authorization", auth_key.clone()))
            .to_request();
        let no_escape: FrontendResult = test::call_and_read_body_json(&app, req).await;
        assert!(no_escape.toggles.iter().all(|toggle| toggle.enabled));

        let req = test::TestRequest::get()
            .uri("/api/proxy?properties[companyId]=bricks")
            .insert_header(ContentType::json())
            .insert_header(("Authorization", auth_key.clone()))
            .to_request();
        let no_escape: FrontendResult = test::call_and_read_body_json(&app, req).await;
        assert!(no_escape.toggles.iter().all(|toggle| toggle.enabled));

        let req = test::TestRequest::get()
        .uri("/api/proxy/all?properties[companyId]=bricks")
        .insert_header(ContentType::json())
        .insert_header(("Authorization", auth_key.clone()))
        .to_request();
        let no_escape: FrontendResult = test::call_and_read_body_json(&app, req).await;
        assert!(no_escape.toggles.iter().all(|toggle| toggle.enabled));

Note: The flags are evaluated correctly with the custom properties using POST calls but not on the ones that rely on GET such as the ones from the Flutter / Dart SDK.

Unleash version

v19.5.0

Subscription type

Enterprise

Hosting type

Self-hosted

SDK information (language and version)

curl and Dart SDK

@sighphyre
Copy link
Member

Thank you for the most excellent bug report!

We've patched this and released Edge 19.5.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants