Skip to content

test(php): cover OpenFeature in all weblog environments - #7393

Open
leoromanovsky wants to merge 8 commits into
mainfrom
leo.romanovsky/php-openfeature-all-environments
Open

test(php): cover OpenFeature in all weblog environments#7393
leoromanovsky wants to merge 8 commits into
mainfrom
leo.romanovsky/php-openfeature-all-environments

Conversation

@leoromanovsky

@leoromanovsky leoromanovsky commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Motivation

A customer found that an application error handler can convert a provider warning into an exception. OpenFeature then returns the code default with a GENERAL error.

The existing PHP FFE tests called the native Datadog client. They did not cross the OpenFeature provider and logger boundary where this failure occurred.

flowchart LR
    App["Application"] --> Client["OpenFeature client"]
    Client --> Provider["Datadog provider"]
    Provider --> Evaluator["Datadog evaluator"]
    Provider -. "warning" .-> Handler["Application error handler"]
    Handler --> Exception["Exception"]
    Exception --> Error["Code default plus GENERAL error"]

    Test["Previous FFE test"] --> Endpoint["POST /ffe"]
    Endpoint --> Native["Native Datadog client"]
    Native --> Evaluator
    Test -. "missed this boundary" .-> Provider
Loading

The OpenFeature PHP SDK requires PHP 8 or later. System tests still support PHP 7. PHP 7 must keep the /ffe contract when the SDK is unavailable.

Changes and Decisions

The /ffe endpoint now uses OpenFeature by default. Tests that need the native client can set evaluationApi to native.

The generic test omits evaluationApi. An available provider must return the configured value. An unavailable provider must return the supplied default with ERROR and PROVIDER_NOT_READY.

flowchart TD
    Test["Generic FFE test"] --> Endpoint["POST /ffe"]
    Endpoint --> Default["Default to OpenFeature"]
    Default --> Available{"Provider available?"}
    Available -->|"Yes"| Success["Configured value and no error"]
    Available -->|"No"| Fallback["Supplied default<br/>ERROR<br/>PROVIDER_NOT_READY"]
    Success --> Contract["Contract passes"]
    Fallback --> Contract
Loading

The shared PHP installer adds the OpenFeature SDK on PHP 8 and later. Laravel and Symfony use the shared /ffe handler. PHP 7 marks provider-dependent tests as unavailable but keeps the generic contract test enabled.

The PHP 8 success path depends on DataDog/dd-trace-php#4071.

Validation

These local runs used this PR at 0dad5d48bec63cffdd206b724013d26f497c0c8c. They used the CI-built ARM64 package from dd-trace-php bf360ef80839f483179e37215536d1713116167c.

TEST_LIBRARY=php WEBLOG_VARIANT=php-fpm-8.2 ./run.sh FEATURE_FLAGGING_AND_EXPERIMENTATION
37 passed, 9 skipped, 2735 deselected in 153.98s

TEST_LIBRARY=php WEBLOG_VARIANT=laravel11x ./run.sh FEATURE_FLAGGING_AND_EXPERIMENTATION tests/ffe/test_dynamic_evaluation.py::Test_FFE_OpenFeature_Evaluation
1 passed in 34.02s

TEST_LIBRARY=php WEBLOG_VARIANT=symfony7x ./run.sh FEATURE_FLAGGING_AND_EXPERIMENTATION tests/ffe/test_dynamic_evaluation.py::Test_FFE_OpenFeature_Evaluation
1 passed in 34.07s

TEST_LIBRARY=php WEBLOG_VARIANT=php-fpm-7.4 ./run.sh FEATURE_FLAGGING_AND_EXPERIMENTATION
3 passed, 9 skipped, 29 xfailed, 5 xpassed, 2735 deselected in 210.78s

The PHP-FPM 8.2 image used PHP 8.2.32. All four images reported tracer version 1.24.0+dev.bf360ef80839f483179e37215536d1713116167c.

@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

CODEOWNERS have been resolved as:

docs/understand/weblogs/end-to-end_weblog.md                            @DataDog/system-tests-core
manifests/php.yml                                                       @DataDog/apm-php @DataDog/asm-php
tests/ffe/test_dynamic_evaluation.py                                    @DataDog/feature-flagging-and-experimentation-sdk @DataDog/system-tests-core
utils/build/docker/php/apache-mod/build.sh                              @DataDog/apm-php @DataDog/system-tests-core
utils/build/docker/php/common/ffe.php                                   @DataDog/apm-php @DataDog/system-tests-core
utils/build/docker/php/common/install_ddtrace.sh                        @DataDog/apm-php @DataDog/system-tests-core
utils/build/docker/php/weblogs/laravel11x/routes/web.php                @DataDog/apm-php @DataDog/system-tests-core
utils/build/docker/php/weblogs/symfony7x/src/Controller/AppController.php  @DataDog/apm-php @DataDog/system-tests-core

@datadog-prod-us1-3

datadog-prod-us1-3 Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 54a205d | Docs | Datadog PR Page | Give us feedback!

@leoromanovsky

Copy link
Copy Markdown
Contributor Author

Validated against the current PHP fix build.

  • system-tests head: 0dad5d48bec63cffdd206b724013d26f497c0c8c
  • dd-trace-php fix head: bf360ef80839f483179e37215536d1713116167c
  • CI-built ARM64 PHP package: 1.24.0+dev.bf360ef80839f483179e37215536d1713116167c
  • PHP-FPM runtime: PHP 8.2.32

Local results:

php-fpm-8.2, complete FEATURE_FLAGGING_AND_EXPERIMENTATION scenario
37 passed, 9 skipped, 2735 deselected in 153.98s

laravel11x, Test_FFE_OpenFeature_Evaluation
1 passed in 34.02s

symfony7x, Test_FFE_OpenFeature_Evaluation
1 passed in 34.07s

php-fpm-7.4, complete FEATURE_FLAGGING_AND_EXPERIMENTATION scenario
3 passed, 9 skipped, 29 xfailed, 5 xpassed, 2735 deselected in 210.78s

The current GitHub Actions run does not use this PHP build:

  • All 12 production PHP jobs use php@1.23.1. Their only failed step is the FFE scenario. These jobs need a release that contains the PHP fix.
  • The 12 PHP 8 development jobs use php@1.24.0+dev.5bf45ce4ececff3bc5c046464636ce758c839a3c. That build predates the fix. Their FFE failures should stop after [java] Update mssql-jdbc version #4071 merges and the development package refreshes. They do not need a public release.
  • All 27 development PHP jobs also fail unrelated AppSec telemetry scenarios. The 15 PHP 7 development jobs do not fail the FFE step. Their red status comes only from those AppSec failures.

Therefore, the PHP fix will unblock the FFE failures. It will not make every PHP job green because the AppSec failures are separate.

@leoromanovsky
leoromanovsky marked this pull request as ready for review July 29, 2026 16:14
@leoromanovsky
leoromanovsky requested review from a team as code owners July 29, 2026 16:14
@leoromanovsky
leoromanovsky requested review from pavlokhrebto and typotter and removed request for a team July 29, 2026 16:15

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 54a205d2c7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

assert self.response.status_code == 200, f"Flag evaluation failed: {self.response.text}"
result = json.loads(self.response.text)

if result.get("errorCode") == "PROVIDER_NOT_READY":

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Require configured evaluation on supported PHP weblogs

On PHP 8 weblogs, where this commit installs the OpenFeature SDK and activates the test, this branch lets the test pass when OpenFeature is completely broken or unwired. The PHP handler catches any Throwable—including missing classes, provider construction failures, or incompatible SDK calls—and maps it to PROVIDER_NOT_READY, so every supported weblog could return the default without this test detecting the regression. Reserve this fallback behavior for PHP 7 through a separate manifest-scoped contract test, and require the configured true value here.

Useful? React with 👍 / 👎.

Comment thread manifests/php.yml
Comment on lines +3 to +4
refs:
- &php7 "apache-mod-7.0, apache-mod-7.0-zts, apache-mod-7.1, apache-mod-7.1-zts, apache-mod-7.2, apache-mod-7.2-zts, apache-mod-7.3, apache-mod-7.3-zts, apache-mod-7.4, apache-mod-7.4-zts, php-fpm-7.0, php-fpm-7.1, php-fpm-7.2, php-fpm-7.3, php-fpm-7.4"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid introducing the PHP manifest's first anchor

php.yml had no refs section before this change, so this adds its first reusable anchor. .cursor/rules/test-activation.mdc permits new references only in manifests that already contain references and with explicit approval; expand this weblog list at the affected conditions rather than introducing refs: here.

AGENTS.md reference: AGENTS.md:L24-L24

Useful? React with 👍 / 👎.

def setup_openfeature_evaluation(self) -> None:
self.flag_key = "openfeature-evaluation"
config = make_ufc_fixture(self.flag_key, variation_type="BOOLEAN")
rc.tracer_rc_state.reset().set_config(f"{RC_PATH}/openfeature-evaluation/config", config).apply()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep Remote Config acknowledgement out of setup

apply() calls send_state() with acknowledgement waiting enabled and can raise when RC delivery or acknowledgement times out. Because an exception from setup_openfeature_evaluation aborts the entire scenario rather than producing an isolated test failure, make this setup operation non-throwing and perform its validation in the matching test, as required by .cursor/rules/pr-review.mdc.

AGENTS.md reference: AGENTS.md:L33-L35

Useful? React with 👍 / 👎.

Comment on lines +29 to +31
if [[ "$(printf '%s\n' "$PHP_VERSION" "8.0" | sort -V | head -n1)" = "8.0" ]]; then
COMPOSER_DISCARD_CHANGES=true composer require "open-feature/sdk:^2.2" \
--prefer-dist --no-interaction --ignore-platform-req=ext-mbstring

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip OpenFeature installation for the parametric image

This shared installer is also called by utils/build/docker/php/parametric/Dockerfile, where the locked application dependencies are installed under /binaries and no FFE endpoint uses OpenFeature. On that PHP 8.2 build, this unconditional command instead runs from /var/www/html, creates or updates a separate Composer project, and adds an unnecessary unpinned network resolution that can fail an otherwise reproducible parametric build. Guard the requirement to weblog images that actually expose /ffe, or install it in the weblog-specific build path.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant